Skip to content

Commit

Permalink
fix: adjust the broadcasts for the slightly different payload
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer committed Dec 25, 2023
1 parent 7c03244 commit ad9053c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
9 changes: 5 additions & 4 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion assets/chat/js/messages/ChatBroadcastMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion assets/chat/js/messages/ChatEventMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion assets/chat/js/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ad9053c

Please sign in to comment.