add capability to remove reactions

This commit is contained in:
marlon-erler
2026-04-07 18:48:01 +00:00
parent ad978807dc
commit 4bd7126a76
6 changed files with 81 additions and 64 deletions
+16 -11
View File
@@ -76,26 +76,31 @@ export default class ChatMessageViewModel {
};
// reactions
addReaction = (reaction: ChatMessageReaction): void => {
handleReaction = (reaction: ChatMessageReaction): void => {
function setReaction(mapState: React.MapState<any>) {
if (reaction.isDeleting) {
mapState.remove(reaction.sender);
} else {
mapState.set(reaction.sender, reaction);
}
}
switch (reaction.content) {
case ReactionSymbols.ThumbsUp:
return this.reactionsThumbsUp.set(reaction.sender, reaction);
return setReaction(this.reactionsThumbsUp);
case ReactionSymbols.Check:
return this.reactionsCheck.set(reaction.sender, reaction);
return setReaction(this.reactionsCheck);
case ReactionSymbols.Attention:
return this.reactionsAttention.set(reaction.sender, reaction);
return setReaction(this.reactionsAttention);
case ReactionSymbols.DoubleAttention:
return this.reactionsDoubleAttention.set(
reaction.sender,
reaction,
);
return setReaction(this.reactionsDoubleAttention);
case ReactionSymbols.Question:
return this.reactionsQuestion.set(reaction.sender, reaction);
return setReaction(this.reactionsQuestion);
}
};
sendReaction = (content: ReactionSymbols): void => {
this.messagePageViewModel.sendReaction(this.chatMessage.id, content);
sendReaction = (content: ReactionSymbols, isDeleting: boolean): void => {
this.messagePageViewModel.sendReaction(this.chatMessage.id, content, isDeleting);
};
// load
+1 -1
View File
@@ -181,7 +181,7 @@ export default class ChatViewModel {
);
chatModel.reactionHandlerManager.addHandler(
(reaction: ChatMessageReaction) => {
this.messagePageViewModel.showReaction(reaction);
this.messagePageViewModel.handleReaction(reaction);
},
);