web: add notification sound

This commit is contained in:
Tulir Asokan 2024-11-09 22:23:25 +02:00
parent 00a2070ff3
commit bc550cbff4
4 changed files with 5 additions and 4 deletions

View file

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8"/>
<link rel="icon" type="image/png" href="/gomuks.png"/>
<link rel="icon" type="image/png" href="gomuks.png"/>
<link rel="stylesheet" media="(prefers-color-scheme: light)" href="_gomuks/codeblock/github.css" />
<link rel="stylesheet" media="(prefers-color-scheme: dark)" href="_gomuks/codeblock/github-dark.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
@ -11,5 +11,6 @@
<body>
<div id="root"></div>
<script type="module" src="src/main.tsx"></script>
<audio id="default-notification-sound" preload="auto" src="sounds/bright.flac"></audio>
</body>
</html>

Binary file not shown.

Binary file not shown.

View file

@ -298,6 +298,9 @@ export class StateStore {
const roomName = room.meta.current.name ?? "Unnamed room"
const senderName = memberEvt?.content.displayname ?? evt.sender
const title = senderName === roomName ? senderName : `${senderName} (${roomName})`
if (sound) {
(document.getElementById("default-notification-sound") as HTMLAudioElement)?.play()
}
const notif = new Notification(title, {
body,
icon,
@ -309,9 +312,6 @@ export class StateStore {
room.openNotifications.set(rowid, notif)
notif.onclose = () => room.openNotifications.delete(rowid)
notif.onclick = () => this.onClickNotification(room.roomID)
if (sound) {
// TODO play sound
}
}
onClickNotification(roomID: RoomID) {