|
@@ -1,5 +1,5 @@
|
|
|
<script lang="ts">
|
|
|
- import { settings } from '$lib/stores';
|
|
|
+ import { settings, playingNotificationSound } from '$lib/stores';
|
|
|
import DOMPurify from 'dompurify';
|
|
|
|
|
|
import { marked } from 'marked';
|
|
@@ -17,8 +17,15 @@
|
|
|
}
|
|
|
|
|
|
if ($settings?.notificationSound ?? true) {
|
|
|
- const audio = new Audio(`/audio/notification.mp3`);
|
|
|
- audio.play();
|
|
|
+ if (!$playingNotificationSound) {
|
|
|
+ playingNotificationSound.set(true);
|
|
|
+
|
|
|
+ const audio = new Audio(`/audio/notification.mp3`);
|
|
|
+ audio.play().finally(() => {
|
|
|
+ // Ensure the global state is reset after the sound finishes
|
|
|
+ playingNotificationSound.set(false);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
</script>
|