From b9aeaf29a4f8094e1da448df79a699916d4a5365 Mon Sep 17 00:00:00 2001 From: Matthew Remmel Date: Fri, 26 Sep 2025 11:31:04 -0400 Subject: [PATCH] Disable notification sound when tab is focused --- src/app/components/NewNotificationSound.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/components/NewNotificationSound.svelte b/src/app/components/NewNotificationSound.svelte index 8e95d84..a6d2371 100644 --- a/src/app/components/NewNotificationSound.svelte +++ b/src/app/components/NewNotificationSound.svelte @@ -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() } }