Skip to content

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

FIX: ensures last read is updated on exit (#26691)

Joffrey JAFFEUX08ff0bac297d
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs b/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
index ae604216918..62ca9e26c8c 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-channel.gjs
@@ -111,6 +111,7 @@ export default class ChatChannel extends Component {
this.#cancelHandlers();
removeOnPresenceChange(this.onPresenceChangeCallback);
this.subscriptionManager.teardown();
+ this.updateLastReadMessage();
}
@action
@@ -415,15 +416,12 @@ export default class ChatChannel extends Component {
}
schedule("afterRender", () => {
- let lastFullyVisibleMessageNode = null;
-
- this.scrollable
- .querySelectorAll(".chat-message-container")
- .forEach((item) => {
- if (checkMessageBottomVisibility(this.scrollable, item)) {
- lastFullyVisibleMessageNode = item;
- }
- });
+ const messages = this.scrollable.querySelectorAll(
+ ".chat-message-container"
+ );
+ let lastFullyVisibleMessageNode = Array.from(messages)
+ .reverse()
+ .find((item) => checkMessageBottomVisibility(this.scrollable, item));
if (!lastFullyVisibleMessageNode) {
return;