diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index 5c59477c..28593286 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -736,6 +736,7 @@ class Chat { win.lastmessage && !win.lastmessage.target && win.lastmessage.user && + (!win.lastmessage.ignored || win.lastmessage.continued) && // messages should not appear as "continued" if the previous message is ignored and was the start of the thread win.lastmessage.user.username === message.user.username; // set highlighted state message.highlighted = this.shouldHighlightMessage(message); diff --git a/assets/chat/js/messages/ChatMessage.js b/assets/chat/js/messages/ChatMessage.js index f5a2d5ff..c37b8f39 100644 --- a/assets/chat/js/messages/ChatMessage.js +++ b/assets/chat/js/messages/ChatMessage.js @@ -146,4 +146,20 @@ export default class ChatMessage extends ChatUIMessage { this.ui.classList.toggle('msg-own', isOwn); this.isown = isOwn; } + + /** + * @param {ChatMessage} lastMessage + */ + setContinued(lastMessage) { + this.continued = + lastMessage && + !lastMessage.target && + lastMessage.user && + (!lastMessage.ignored || lastMessage.continued) && // messages should not appear as "continued" if the previous message is ignored and was the start of the thread + lastMessage.user.username === this.user.username; + + this.ui.classList.toggle('msg-continue', this.continued); + const ctrl = this.ui.querySelector('.ctrl'); + if (ctrl) ctrl.textContent = this.continued ? '' : ': '; + } } diff --git a/assets/chat/js/window.js b/assets/chat/js/window.js index 1a22edc8..fc67e6ca 100644 --- a/assets/chat/js/window.js +++ b/assets/chat/js/window.js @@ -122,7 +122,7 @@ class ChatWindow extends EventEmitter { * this window. */ updateMessages(chat) { - for (const message of this.messages) { + for (const [i, message] of this.messages.entries()) { if (message.type !== MessageTypes.UI) { message.updateTimeFormat(); } @@ -134,6 +134,7 @@ class ChatWindow extends EventEmitter { message.ignore(chat.ignored(username, message.message)); message.highlight(chat.shouldHighlightMessage(message)); if (message.type === MessageTypes.USER) { + message.setContinued(this.messages[i - 1]); message.setTag(chat.taggednicks.get(username)); } message.setTagTitle(chat.taggednotes.get(username));