Skip to content

Commit

Permalink
Handle moderate reply
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasReumann committed Aug 22, 2023
1 parent c9ea23f commit ec1fb75
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions web/ts/api/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion web/ts/components/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ec1fb75

Please sign in to comment.