Ignore emoji when removing reactions
This commit is contained in:
parent
90d8313614
commit
1dc353f089
1 changed files with 7 additions and 24 deletions
|
@ -3149,24 +3149,20 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
this.get('conversationId')
|
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')) {
|
if (reaction.get('remove')) {
|
||||||
log.info('Removing reaction for message', messageId);
|
log.info('Removing reaction for message', messageId);
|
||||||
const newReactions = reactions.filter(
|
const newReactions = reactions.filter(
|
||||||
re =>
|
re => re.fromId !== reaction.get('fromId')
|
||||||
re.emoji !== reaction.get('emoji') ||
|
|
||||||
re.fromId !== reaction.get('fromId')
|
|
||||||
);
|
);
|
||||||
this.set({ reactions: newReactions });
|
this.set({ reactions: newReactions });
|
||||||
|
|
||||||
reactionToRemove = {
|
|
||||||
emoji: reaction.get('emoji'),
|
|
||||||
targetAuthorUuid: reaction.get('targetAuthorUuid'),
|
|
||||||
targetTimestamp: reaction.get('targetTimestamp'),
|
|
||||||
};
|
|
||||||
|
|
||||||
await window.Signal.Data.removeReactionFromConversation({
|
await window.Signal.Data.removeReactionFromConversation({
|
||||||
emoji: reaction.get('emoji'),
|
emoji: reaction.get('emoji'),
|
||||||
fromId: reaction.get('fromId'),
|
fromId: reaction.get('fromId'),
|
||||||
|
@ -3181,15 +3177,6 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
newReactions.push(reaction.toJSON());
|
newReactions.push(reaction.toJSON());
|
||||||
this.set({ reactions: newReactions });
|
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({
|
await window.Signal.Data.addReaction({
|
||||||
conversationId: this.get('conversationId'),
|
conversationId: this.get('conversationId'),
|
||||||
emoji: reaction.get('emoji'),
|
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;
|
const newCount = (this.get('reactions') || []).length;
|
||||||
log.info(
|
log.info(
|
||||||
`Done processing reaction for message ${messageId}. Went from ${count} to ${newCount} reactions.`
|
`Done processing reaction for message ${messageId}. Went from ${count} to ${newCount} reactions.`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue