mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-19 18:13:41 -05:00
web: add notification sound
This commit is contained in:
parent
00a2070ff3
commit
bc550cbff4
4 changed files with 5 additions and 4 deletions
|
@ -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>
|
||||
|
|
BIN
web/public/sounds/bright.flac
Normal file
BIN
web/public/sounds/bright.flac
Normal file
Binary file not shown.
BIN
web/public/sounds/descending.flac
Normal file
BIN
web/public/sounds/descending.flac
Normal file
Binary file not shown.
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue