Skip to content

Commit

Permalink
Fix some ignore issues (#521)
Browse files Browse the repository at this point in the history
* fix: harsh ignore hiding ui messages

* fix: updateMessages func not running when after hitting a system message

* feat: dont autocomplete ignored users
  • Loading branch information
vyneer authored Oct 14, 2024
1 parent 953e9fa commit c690405
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
21 changes: 17 additions & 4 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,15 @@ class Chat {
win.addMessage(this, message);

// Hide the message if the user is ignored
if (this.ignored(message.user?.username, message.message)) {
if (
![
MessageTypes.UI,
MessageTypes.INFO,
MessageTypes.ERROR,
MessageTypes.STATUS,
].includes(message.type) &&
this.ignored(message.user?.username, message.message)
) {
message.ignore();
}

Expand Down Expand Up @@ -1033,9 +1041,10 @@ class Chat {
if (data.recipient) {
users.push(this.addUser(data.recipient));
}
users.forEach((u) =>
this.autocomplete.add(u.displayName, false, Date.now()),
);
users.forEach((u) => {
if (this.ignored(u.username)) return;
this.autocomplete.add(u.displayName, false, Date.now());
});
}
}

Expand Down Expand Up @@ -1639,6 +1648,8 @@ class Chat {
if (!failure) {
validUsernames.forEach((username) => {
this.ignore(username, true);
const user = this.users.get(username);
if (user) this.autocomplete.remove(user.displayName, true);
});
const resultArray = Array.from(validUsernames.values());
const resultMessage =
Expand Down Expand Up @@ -1669,6 +1680,8 @@ class Chat {
if (!failure) {
validUsernames.forEach((username) => {
this.ignore(username, false);
const user = this.users.get(username);
if (user) this.autocomplete.add(user.displayName, false, Date.now());
});
const haveOrHas = parts.length === 1 ? 'has' : 'have';
MessageBuilder.status(
Expand Down
11 changes: 9 additions & 2 deletions assets/chat/js/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,19 @@ class ChatWindow extends EventEmitter {
}

if (message.user?.isSystem()) {
return;
continue;
}

const username = message.user?.username;

if (message.type !== MessageTypes.UI) {
if (
![
MessageTypes.UI,
MessageTypes.INFO,
MessageTypes.ERROR,
MessageTypes.STATUS,
].includes(message.type)
) {
message.ignore(chat.ignored(username, message.message));
}

Expand Down

0 comments on commit c690405

Please sign in to comment.