Skip to content

Commit

Permalink
fix: error on trying to apply user tags to server broadcasts
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer committed Dec 11, 2023
1 parent 9d0f50e commit 1b9172a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,15 +743,15 @@ class Chat {
message.slashme =
message.message.substring(0, 4).toLowerCase() === '/me ';
// check if this is the current users message
message.isown = message.user.username === this.user.username;
message.isown = message.user?.username === this.user.username;
// get mentions from message
message.mentioned = Chat.extractNicks(message.message).filter((a) =>
this.users.has(a.toLowerCase()),
);
// set tagged state
message.tag = this.taggednicks.get(message.user.username);
message.tag = this.taggednicks.get(message.user?.username);
// set tagged note
message.title = this.taggednotes.get(message.user.username) || '';
message.title = this.taggednotes.get(message.user?.username) || '';
}

// Populate highlight for this $message
Expand Down Expand Up @@ -1266,8 +1266,9 @@ class Chat {
).into(this);
}
} else {
const user =
this.users.get(data.nick.toLowerCase()) ?? new ChatUser(data.user);
const user = data.nick
? this.users.get(data.nick.toLowerCase()) ?? new ChatUser(data.user)
: null;
MessageBuilder.broadcast(data.data, user, data.timestamp).into(this);
}
}
Expand Down
2 changes: 1 addition & 1 deletion assets/chat/js/messages/ChatBroadcastMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class ChatBroadcastMessage extends ChatEventMessage {
}

buildUserTemplate(chat = null) {
if (this.user.displayName !== '') {
if (this.user && this.user.displayName !== '') {
const colorFlair = usernameColorFlair(chat.flairs, this.user);

/** @type HTMLAnchorElement */
Expand Down

0 comments on commit 1b9172a

Please sign in to comment.