From ec1fb7571f2197af72105baf2436387a3ccfba3f Mon Sep 17 00:00:00 2001 From: Matthias Reumann Date: Tue, 22 Aug 2023 09:36:15 +0200 Subject: [PATCH] Handle moderate reply --- web/ts/api/chat.ts | 7 +++++++ web/ts/components/chat.ts | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/web/ts/api/chat.ts b/web/ts/api/chat.ts index fcbce6ecd..7bf8753c7 100644 --- a/web/ts/api/chat.ts +++ b/web/ts/api/chat.ts @@ -92,6 +92,13 @@ export class ChatMessageArray { this.messages = filtered; } + approveReply(m: ChatMessage) { + const base = this.messages.find((msg) => msg.ID === m.replyTo.Int64); + const filtered = base.replies.filter((msg) => msg.ID !== m.ID); + filtered.push(Object.assign(new ChatMessage(), m)); + base.replies = filtered; + } + retract(msg: ChatMessage, isAdmin: boolean) { if (isAdmin) { this.messages.find((m) => m.ID === msg.ID).visible = false; diff --git a/web/ts/components/chat.ts b/web/ts/components/chat.ts index e260f88c2..1b187e3f4 100644 --- a/web/ts/components/chat.ts +++ b/web/ts/components/chat.ts @@ -232,7 +232,8 @@ export function chatContext(streamId: number, user: User, isRecording: boolean): handleApprove(msg: ChatMessage) { this.preprocessors.forEach((f) => f(msg, this.user)); - this.messages.approve(msg); + if (msg.replyTo.Valid) this.messages.approveReply(msg); + else this.messages.approve(msg); }, handleRetract(msg: ChatMessage) {