mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 02:47:06 +00:00
Disable notification sound when tab is focused
This commit is contained in:
@@ -5,10 +5,19 @@
|
|||||||
|
|
||||||
let audioElement: HTMLAudioElement
|
let audioElement: HTMLAudioElement
|
||||||
|
|
||||||
|
let enabled = $state(false)
|
||||||
|
|
||||||
|
document.addEventListener("visibilitychange", () => {
|
||||||
|
if (document.hidden) {
|
||||||
|
enabled = true
|
||||||
|
} else {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
})
|
||||||
let notificationCount = $state($notifications.size)
|
let notificationCount = $state($notifications.size)
|
||||||
|
|
||||||
const playSound = () => {
|
const playSound = () => {
|
||||||
if ($userSettingsValues.play_notification_sound) {
|
if (enabled && $userSettingsValues.play_notification_sound) {
|
||||||
audioElement.play()
|
audioElement.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user