FIX: ensures removing a reaction doesn’t remove others (#20869)

This commit is contained in:
Joffrey JAFFEUX
2023-03-29 08:39:52 +02:00
committed by GitHub
parent b854fa8cdb
commit 69de5b161f
3 changed files with 62 additions and 23 deletions
@@ -151,18 +151,23 @@ export default class ChatMessage {
}
existingReaction.users.pushObject(actor);
} else {
existingReaction.count = existingReaction.count - 1;
const existingUserReaction = existingReaction.users.find(
(user) => user.id === actor.id
);
if (!existingUserReaction) {
return;
}
if (selfReaction) {
existingReaction.reacted = false;
}
if (existingReaction.count === 0) {
if (existingReaction.count === 1) {
this.reactions.removeObject(existingReaction);
} else {
existingReaction.users.removeObject(
existingReaction.users.find((user) => user.id === actor.id)
);
existingReaction.count = existingReaction.count - 1;
existingReaction.users.removeObject(existingUserReaction);
}
}
} else {