-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/death-message
- Loading branch information
Showing
17 changed files
with
402 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { usernameColorFlair } from './ChatUserMessage'; | ||
import ChatEventMessage from './ChatEventMessage'; | ||
import MessageTypes from './MessageTypes'; | ||
|
||
export default class ChatBroadcastMessage extends ChatEventMessage { | ||
constructor(message, user, timestamp = null) { | ||
super(message, timestamp); | ||
this.type = MessageTypes.BROADCAST; | ||
this.user = user; | ||
} | ||
|
||
buildUserTemplate(chat = null) { | ||
if (this.user.isSystem()) { | ||
return []; | ||
} | ||
|
||
const colorFlair = usernameColorFlair(chat.flairs, this.user); | ||
|
||
/** @type HTMLAnchorElement */ | ||
const user = document | ||
.querySelector('#user-template') | ||
?.content.cloneNode(true).firstElementChild; | ||
user.title = this.title; | ||
user.classList.add(colorFlair?.name); | ||
user.innerText = this.user.displayName; | ||
|
||
const ctrl = document.createElement('span'); | ||
ctrl.classList.toggle('ctrl'); | ||
|
||
if (this.slashme) { | ||
return [user, ctrl, ' ']; | ||
} | ||
|
||
ctrl.innerText = ': '; | ||
|
||
return [user, ctrl]; | ||
} | ||
|
||
html(chat = null) { | ||
const eventTemplate = super.html(chat); | ||
|
||
const text = eventTemplate.querySelector('.event-bottom')?.innerHTML; | ||
eventTemplate.querySelector('.event-bottom').remove(); | ||
eventTemplate.querySelector('.event-info').innerHTML = text; | ||
|
||
const user = this.buildUserTemplate(chat); | ||
|
||
eventTemplate.querySelector('.event-icon').classList.add('broadcast-icon'); | ||
eventTemplate.querySelector('.event-info').prepend(...user); | ||
|
||
const classes = Array.from(eventTemplate.classList); | ||
const attributes = eventTemplate | ||
.getAttributeNames() | ||
.reduce((object, attributeName) => { | ||
if (attributeName === 'class') return object; | ||
return { | ||
...object, | ||
[attributeName]: eventTemplate.getAttribute(attributeName), | ||
}; | ||
}, {}); | ||
|
||
return this.wrap(eventTemplate.innerHTML, classes, attributes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.