add backend for message reactions

This commit is contained in:
marlon-erler
2026-04-06 20:47:49 +00:00
parent 7ccb237eac
commit bb0a71a01f
7 changed files with 306 additions and 11 deletions
+32 -1
View File
@@ -1,6 +1,12 @@
import * as React from "bloatless-react";
import { ChatMessage, ChatMessageStatus } from "../../Model/Chat/chatModel";
import {
ChatMessage,
ChatMessageReaction,
ChatMessageReactionReference,
ChatMessageStatus,
ReactionSymbol,
} from "../../Model/Chat/chatModel";
import CoreViewModel from "../Global/coreViewModel";
import MessagePageViewModel from "../Pages/messagePageViewModel";
@@ -19,6 +25,12 @@ export default class ChatMessageViewModel {
);
sentByUser: boolean;
reactionsThumbsUp = new React.MapState<ChatMessageReaction>();
reactionsCheck = new React.MapState<ChatMessageReaction>();
reactionsAttention = new React.MapState<ChatMessageReaction>();
reactionsDoubleAttention = new React.MapState<ChatMessageReaction>();
reactionsQuestion = new React.MapState<ChatMessageReaction>();
// state
isPresentingInfoModal: React.State<boolean> = new React.State(false);
@@ -42,6 +54,25 @@ export default class ChatMessageViewModel {
this.isPresentingInfoModal.value = false;
};
// reactions
addReaction = (reaction: ChatMessageReaction): void => {
switch (reaction.content) {
case "👍":
return this.reactionsThumbsUp.set(reaction.fileId, reaction);
case "✅":
return this.reactionsCheck.set(reaction.fileId, reaction);
case "❗️":
return this.reactionsAttention.set(reaction.fileId, reaction);
case "‼️":
return this.reactionsDoubleAttention.set(
reaction.fileId,
reaction,
);
case "❓":
return this.reactionsQuestion.set(reaction.fileId, reaction);
}
};
// load
loadData = (): void => {
this.channel = this.chatMessage.channel;