Added sound.
This commit is contained in:
parent
a7e0e5a3f8
commit
54920e1545
@ -263,7 +263,10 @@ class NotificationAudio {
|
||||
this.schedule = new Schedule(timeout);
|
||||
}
|
||||
|
||||
sounds = ["/audio/soundfx.d_beep3.mp3"];
|
||||
sounds = [
|
||||
"/audio/soundfx.d_beep3.mp3",
|
||||
"/audio/mention1.wav"
|
||||
];
|
||||
|
||||
play(soundIndex = 0) {
|
||||
this.schedule.delay(() => {
|
||||
|
BIN
src/snek/static/audio/mention1.wav
Normal file
BIN
src/snek/static/audio/mention1.wav
Normal file
Binary file not shown.
@ -116,11 +116,20 @@
|
||||
|
||||
setInterval(updateTimes, 1000);
|
||||
|
||||
function isMention(message){
|
||||
const mentionText = '@{{ user.username.value }}';
|
||||
return message.toLowerCase().includes(mentionText);
|
||||
}
|
||||
|
||||
app.addEventListener("channel-message", (data) => {
|
||||
if (data.channel_uid !== channelUid) return;
|
||||
|
||||
if (data.username !== "{{ user.username.value }}") {
|
||||
if(isMention(data.message)){
|
||||
app.playSound(1);
|
||||
}else{
|
||||
app.playSound(0);
|
||||
}
|
||||
}
|
||||
|
||||
const messagesContainer = document.querySelector(".chat-messages");
|
||||
@ -128,10 +137,6 @@
|
||||
const doScrollDownBecauseLastMessageIsVisible = !lastMessage || isElementVisible(lastMessage);
|
||||
|
||||
const message = document.createElement("div");
|
||||
message.dataset.color = data.color;
|
||||
message.dataset.created_at = data.created_at;
|
||||
message.dataset.user_nick = data.user_nick;
|
||||
message.dataset.uid = data.uid;
|
||||
message.innerHTML = data.html;
|
||||
document.querySelector(".chat-messages").appendChild(message.firstChild);
|
||||
updateLayout(doScrollDownBecauseLastMessageIsVisible);
|
||||
|
Loading…
Reference in New Issue
Block a user