Disable notification sound when tab is focused
This commit is contained in:
parent
65e3f81f36
commit
b9aeaf29a4
1 changed files with 10 additions and 1 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue