guard around potential crashes

This commit is contained in:
2026-09-02 18:38:38 +02:00
parent 9c3fd4c1a2
commit e98293fa7c
5 changed files with 32 additions and 16 deletions
+3 -3
View File
@@ -16,6 +16,7 @@
import { onMount, untrack } from 'svelte';
import { fade } from 'svelte/transition';
import { getStreamContext } from '$lib/streamContext.svelte.ts';
import { readStored, writeStored } from '$lib/utils.ts';
import type { Track } from '$lib/types';
const ctx = getStreamContext();
@@ -87,8 +88,7 @@
isSafari = isIOS || isDesktopSafari;
// default volume
const volumeData = localStorage.getItem('volume');
volume = volumeData ? parseFloat(volumeData) : 0.67;
volume = readStored('volume', 0.67);
setVolume(volume);
// set actions for previous/next track media buttons
@@ -181,7 +181,7 @@
if (!volumeBar) return;
volume = seek(event, volumeBar.getBoundingClientRect());
setVolume(volume);
localStorage.setItem('volume', volume.toString());
writeStored('volume', volume);
muted = false;
}