Skip to content

A platform for community discussion. Free, open, simple.

FIX: Clear chat unread counts when reaching the bottom (#40735)

Jarek Radosz6c2cf79cfefd
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
index 30e1e85e660..b06f2e9c86b 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
@@ -446,6 +446,15 @@ export default class ChatChannel extends Component {
return;
}
+ // Clear unread counts optimistically when the latest message is in view.
+ if (
+ !this.messagesLoader.canLoadMoreFuture &&
+ firstMessage.id === this.messagesManager.findLastMessage()?.id
+ ) {
+ this.args.channel.tracking.unreadCount = 0;
+ this.args.channel.tracking.mentionCount = 0;
+ }
+
const lastReadId =
this.args.channel.currentUserMembership?.lastReadMessageId;
if (lastReadId >= firstMessage.id) {