From c3c7b488cc98550bd6193a5b8ba53cc0901e6fd6 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Fri, 4 Feb 2022 15:18:40 +0100 Subject: [PATCH] Reactions: Fix unexpected interactions animation (#1697) --- src/modules/actions/apiUpdaters/messages.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/actions/apiUpdaters/messages.ts b/src/modules/actions/apiUpdaters/messages.ts index 018ab20e1..8b63df8e1 100644 --- a/src/modules/actions/apiUpdaters/messages.ts +++ b/src/modules/actions/apiUpdaters/messages.ts @@ -43,7 +43,9 @@ import { selectLocalAnimatedEmojiEffect, selectLocalAnimatedEmoji, } from '../../selectors'; -import { getMessageContent, isUserId, isMessageLocal } from '../../helpers'; +import { + getMessageContent, isUserId, isMessageLocal, getMessageText, +} from '../../helpers'; const ANIMATION_DELAY = 350; @@ -115,6 +117,12 @@ addReducer('apiUpdate', (global, actions, update: ApiUpdate) => { const { chatId: currentChatId } = selectCurrentMessageList(global) || {}; if (global.activeEmojiInteraction || currentChatId !== update.id) return; + const message = selectChatMessage(global, currentChatId, update.messageId); + + if (!message) return; + + // Workaround for a weird behavior when interaction is received after watching reaction + if (getMessageText(message) !== update.emoji) return; const localEmoji = selectLocalAnimatedEmoji(global, update.emoji);