forked from coracle/flotilla
Fix async bug and add sound component for notification sound
This commit is contained in:
@@ -77,7 +77,7 @@
|
||||
$showUnreadBadge = !$showUnreadBadge
|
||||
|
||||
if (!$showUnreadBadge) {
|
||||
clearBadges()
|
||||
await clearBadges()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {playAlertSound} from "@app/core/state"
|
||||
import {notifications} from "../util/notifications"
|
||||
|
||||
let audioElement: HTMLAudioElement
|
||||
|
||||
let notificationCount = $state($notifications.size)
|
||||
|
||||
const playSound = () => {
|
||||
if ($playAlertSound) {
|
||||
audioElement.play()
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
audioElement.load()
|
||||
|
||||
notifications.subscribe(notifications => {
|
||||
if (notifications.size > notificationCount) {
|
||||
playSound()
|
||||
}
|
||||
|
||||
notificationCount = notifications.size
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<audio bind:this={audioElement} src="/new-notification-3-398649.mp3"></audio>
|
||||
Reference in New Issue
Block a user