Skip to content

Commit

Permalink
fix: msgs shown as continued after ignored ones
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer committed Dec 1, 2023
1 parent 3ded990 commit a2b5c46
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions assets/chat/js/messages/ChatMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? '' : ': ';
}
}
3 changes: 2 additions & 1 deletion assets/chat/js/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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));
Expand Down

0 comments on commit a2b5c46

Please sign in to comment.