2025-09-24 17:32:55 +00:00
|
|
|
<script lang="ts">
|
|
|
|
|
import {onMount} from "svelte"
|
2025-09-24 17:50:01 +00:00
|
|
|
import {userSettingsValues} from "@app/core/state"
|
2026-01-22 22:23:46 +00:00
|
|
|
import {onNotification} from "@app/util/notifications"
|
2025-09-24 17:32:55 +00:00
|
|
|
|
|
|
|
|
let audioElement: HTMLAudioElement
|
|
|
|
|
|
2025-09-26 15:31:04 +00:00
|
|
|
let enabled = $state(false)
|
|
|
|
|
|
|
|
|
|
document.addEventListener("visibilitychange", () => {
|
|
|
|
|
if (document.hidden) {
|
|
|
|
|
enabled = true
|
|
|
|
|
} else {
|
|
|
|
|
enabled = false
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-10-06 18:23:19 +00:00
|
|
|
|
2026-01-07 00:52:15 +00:00
|
|
|
onMount(() => {
|
|
|
|
|
audioElement.load()
|
2026-01-22 22:23:46 +00:00
|
|
|
|
|
|
|
|
const unsubscribe = onNotification(() => {
|
|
|
|
|
if (enabled && $userSettingsValues.alerts_sound) {
|
|
|
|
|
audioElement?.play()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return unsubscribe
|
2025-09-24 17:32:55 +00:00
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<audio bind:this={audioElement} src="/new-notification-3-398649.mp3"></audio>
|