diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index b0f39693..0803f0ad 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -1266,10 +1266,11 @@ class Chat { ).into(this); } } else { - const user = data.nick - ? this.users.get(data.nick.toLowerCase()) ?? new ChatUser(data.user) - : null; - MessageBuilder.broadcast(data.data, user, data.timestamp).into(this); + MessageBuilder.broadcast( + data.data, + new ChatUser(data.user), + data.timestamp, + ).into(this); } } diff --git a/assets/chat/js/messages/ChatBroadcastMessage.js b/assets/chat/js/messages/ChatBroadcastMessage.js index c812bbe0..ed3f3210 100644 --- a/assets/chat/js/messages/ChatBroadcastMessage.js +++ b/assets/chat/js/messages/ChatBroadcastMessage.js @@ -10,7 +10,8 @@ export default class ChatBroadcastMessage extends ChatEventMessage { } buildUserTemplate(chat = null) { - if (this.user && this.user.displayName !== '') { + // User with an id of -1 is the dummy system user used for server broadcasts + if (this.user.id !== -1) { const colorFlair = usernameColorFlair(chat.flairs, this.user); /** @type HTMLAnchorElement */ diff --git a/assets/chat/js/messages/ChatEventMessage.js b/assets/chat/js/messages/ChatEventMessage.js index 9936c719..a239d626 100644 --- a/assets/chat/js/messages/ChatEventMessage.js +++ b/assets/chat/js/messages/ChatEventMessage.js @@ -16,7 +16,7 @@ export default class ChatEventMessage extends ChatMessage { .querySelector('#event-template') ?.content.cloneNode(true).firstElementChild; - if (this.user && this.user.username) + if (this.user && this.user.username && this.user.id !== -1) eventTemplate.dataset.username = this.user.username; if (this.mentioned && this.mentioned.length > 0) eventTemplate.dataset.mentioned = this.mentioned.join(' ').toLowerCase(); diff --git a/assets/chat/js/window.js b/assets/chat/js/window.js index 4b1f7da9..6fd04d91 100644 --- a/assets/chat/js/window.js +++ b/assets/chat/js/window.js @@ -127,7 +127,7 @@ class ChatWindow extends EventEmitter { message.updateTimeFormat(); } - if (message.user) { + if (message.user && message.user.id !== -1) { const { username } = message.user; message.setOwnMessage(username === chat.user.username);