Skip to content

Commit

Permalink
fix issue where reactions won't re-render
Browse files Browse the repository at this point in the history
  • Loading branch information
hannojg committed Mar 5, 2023
1 parent f4c94d8 commit 8bc100b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,9 @@ function addEmojiReaction(reportID, originalReportAction, emoji, skinTone = pref
emoji: emoji.name,
users: [],
};
} else {
// Make a copy of the reaction object so that we can modify it without mutating the original
reactionObject = {...reactionObject};
}

const hasCurrentUserReacted = hasAccountIDReacted(currentUserAccountID, reactionObject.users, skinTone);
Expand Down Expand Up @@ -1281,14 +1284,17 @@ function removeEmojiReaction(reportID, originalReportAction, emoji) {
return;
}

reactionObject.users = _.filter(reactionObject.users, sender => sender.accountID !== currentUserAccountID);
const updatedReactionObject = {
...reactionObject,
};
updatedReactionObject.users = _.filter(reactionObject.users, sender => sender.accountID !== currentUserAccountID);
const updatedReactions = _.filter(

// Replace the reaction object either with the updated one or null if there are no users
_.map(message.reactions, (reaction) => {
if (reaction.emoji === emoji.name) {
if (reaction.users.length === 0) { return null; }
return reactionObject;
return updatedReactionObject;
}
return reaction;
}),
Expand Down

0 comments on commit 8bc100b

Please sign in to comment.