guard around potential crashes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user