diff --git a/ts/models/messages.ts b/ts/models/messages.ts index 87ee76cc889..15b42ab3d83 100644 --- a/ts/models/messages.ts +++ b/ts/models/messages.ts @@ -3148,24 +3148,20 @@ export class MessageModel extends window.Backbone.Model { this.get('conversationId') ); - let reactionToRemove: Partial | undefined; + const oldReaction = reactions.find( + re => re.fromId === reaction.get('fromId') + ); + if (oldReaction) { + this.clearNotifications(oldReaction); + } - let oldReaction: ReactionAttributesType | undefined; if (reaction.get('remove')) { log.info('Removing reaction for message', messageId); const newReactions = reactions.filter( - re => - re.emoji !== reaction.get('emoji') || - re.fromId !== reaction.get('fromId') + re => re.fromId !== reaction.get('fromId') ); this.set({ reactions: newReactions }); - reactionToRemove = { - emoji: reaction.get('emoji'), - targetAuthorUuid: reaction.get('targetAuthorUuid'), - targetTimestamp: reaction.get('targetTimestamp'), - }; - await window.Signal.Data.removeReactionFromConversation({ emoji: reaction.get('emoji'), fromId: reaction.get('fromId'), @@ -3180,15 +3176,6 @@ export class MessageModel extends window.Backbone.Model { newReactions.push(reaction.toJSON()); this.set({ reactions: newReactions }); - oldReaction = reactions.find(re => re.fromId === reaction.get('fromId')); - if (oldReaction) { - reactionToRemove = { - emoji: oldReaction.emoji, - targetAuthorUuid: oldReaction.targetAuthorUuid, - targetTimestamp: oldReaction.targetTimestamp, - }; - } - await window.Signal.Data.addReaction({ conversationId: this.get('conversationId'), emoji: reaction.get('emoji'), @@ -3209,10 +3196,6 @@ export class MessageModel extends window.Backbone.Model { } } - if (reactionToRemove) { - this.clearNotifications(reactionToRemove); - } - const newCount = (this.get('reactions') || []).length; log.info( `Done processing reaction for message ${messageId}. Went from ${count} to ${newCount} reactions.`