Added notification sound.

This commit is contained in:
retoor 2025-01-28 17:24:10 +01:00
parent 4f1a48c197
commit 5aee606d5d
8 changed files with 161 additions and 144 deletions

View File

@ -323,6 +323,21 @@ class App extends EventHandler {
rest = rest
ws = null
rpc = null
sounds = ["/audio/soundfx.d_beep3.mp3"]
playSound(soundIndex) {
if (!soundIndex)
soundIndex = 0
const player = new Audio(this.sounds[soundIndex]);
player.play()
.then(() => {
console.debug("Gave sound notification")
})
.catch((error) => {
console.error("Notification failed:", error);
});
}
constructor() {
super()
this.rooms.push(new Room("General"))

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -51,6 +51,7 @@ class ChatWindowElement extends HTMLElement {
})
const me = this
channelElement.addEventListener("message",(message)=>{
app.playSound(0)
message.detail.element.scrollIntoView()
})

View File

@ -66,6 +66,7 @@ class MessageListElement extends HTMLElement {
this.messageEventSchedule.delay(() => {
me.dispatchEvent(new CustomEvent("message", {detail:obj,bubbles:true}))
})