Disable notification sound when tab is focused

This commit is contained in:
Matthew Remmel
2025-09-26 11:31:04 -04:00
committed by hodlbod
parent 65e3f81f36
commit b9aeaf29a4

View File

@@ -5,10 +5,19 @@
let audioElement: HTMLAudioElement
let enabled = $state(false)
document.addEventListener("visibilitychange", () => {
if (document.hidden) {
enabled = true
} else {
enabled = false
}
})
let notificationCount = $state($notifications.size)
const playSound = () => {
if ($userSettingsValues.play_notification_sound) {
if (enabled && $userSettingsValues.play_notification_sound) {
audioElement.play()
}
}