diff --git a/dao/chat.go b/dao/chat.go
index 18cd74aed..a8f93e01c 100644
--- a/dao/chat.go
+++ b/dao/chat.go
@@ -89,7 +89,7 @@ func (d chatDao) GetReactions(chatID uint) ([]model.ChatReaction, error) {
func (d chatDao) GetVisibleChats(userID uint, streamID uint) ([]model.Chat, error) {
var chats []model.Chat
query := DB.
- Preload("Replies").
+ Preload("Replies", "(visible = 1) OR (user_id = ?)", userID).
Preload("Reactions").
Preload("AddressedToUsers").
Where("(visible = 1) OR (user_id = ?)", userID).
diff --git a/web/template/components/chat.gohtml b/web/template/components/chat.gohtml
index 9062e95d9..be871fd55 100644
--- a/web/template/components/chat.gohtml
+++ b/web/template/components/chat.gohtml
@@ -74,9 +74,7 @@
-
- This message is currently only visible to you and admins.
-
+ This message is currently only visible to you and admins.
@@ -190,26 +188,39 @@
-
+
-
+
-
+
+ This message is currently only visible to you and admins.
-
-
-
-
+
+
+ {{if $course.ModeratedChatEnabled}}
+
+
+
+ {{end}}
-
+
-
+
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) {