Skip to content

Commit

Permalink
fix: undefined class being added to the user (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer authored Jan 8, 2024
1 parent 76bdef7 commit 0c76a5f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assets/chat/js/messages/ChatBroadcastMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class ChatBroadcastMessage extends ChatEventMessage {
.querySelector('#user-template')
?.content.cloneNode(true).firstElementChild;
user.title = this.title;
user.classList.add(colorFlair?.name);
if (colorFlair) user.classList.add(colorFlair.name);
user.innerText = this.user.displayName;

const ctrl = document.createElement('span');
Expand Down
2 changes: 1 addition & 1 deletion assets/chat/js/messages/ChatDonationMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class ChatDonationMessage extends ChatEventMessage {
const colorFlair = usernameColorFlair(chat.flairs, this.user);

user.title = this.title;
user.classList.add(colorFlair?.name);
if (colorFlair) user.classList.add(colorFlair.name);
user.innerText = this.user.displayName;

eventTemplate.querySelector('.event-info').append(
Expand Down
4 changes: 3 additions & 1 deletion assets/chat/js/messages/ChatUserMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export default class ChatUserMessage extends ChatMessage {
const colorFlair = usernameColorFlair(chat.flairs, this.user);
const user = `${this.buildFeatures(this.user, chat)} <a title="${
this.title
}" class="user ${colorFlair?.name}">${this.user.displayName}</a>`;
}" class="${['user', colorFlair?.name].filter(Boolean).join(' ')}">${
this.user.displayName
}</a>`;
return this.wrap(
`${this.buildTime()} ${user}<span class="ctrl">${ctrl}</span> ${this.buildMessageTxt(
chat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class ChatGiftedSubscriptionMessage extends ChatSubscriptionMessa
?.content.cloneNode(true).firstElementChild;

const gifteeColorFlair = usernameColorFlair(chat.flairs, this.giftee);
giftee.classList.add(gifteeColorFlair?.name);
if (gifteeColorFlair) giftee.classList.add(gifteeColorFlair.name);
giftee.innerText = this.giftee.displayName;

const subscriptionInfo = message.querySelector('.event-info');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default class ChatSubscriptionMessage extends ChatEventMessage {
.querySelector('#user-template')
?.content.cloneNode(true).firstElementChild;
user.title = this.title;
user.classList.add(colorFlair?.name);
if (colorFlair) user.classList.add(colorFlair.name);
user.innerText = this.user.displayName;

const tierLabel = this.tierLabel ?? `Tier ${this.tier}`;
Expand Down

0 comments on commit 0c76a5f

Please sign in to comment.