Ignore emoji when removing reactions

This commit is contained in:
Evan Hahn 2021-10-27 10:51:42 -05:00 committed by GitHub
parent 90d8313614
commit 1dc353f089
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3149,24 +3149,20 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
this.get('conversationId')
);
let reactionToRemove: Partial<ReactionType> | 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'),
@ -3181,15 +3177,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
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'),
@ -3210,10 +3197,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
}
}
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.`