guard around potential crashes
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import { browser } from '$app/environment';
|
||||
import { SvelteSet } from 'svelte/reactivity';
|
||||
import { readStored, writeStored } from './utils.ts';
|
||||
|
||||
export const favoritedStreams = new SvelteSet<string>(
|
||||
JSON.parse((browser && localStorage.getItem('favoritedStreams')) || '[]')
|
||||
);
|
||||
export const favoritedStreams = new SvelteSet<string>(readStored('favoritedStreams', []));
|
||||
$effect.root(() => {
|
||||
$effect(() => {
|
||||
localStorage.setItem('favoritedStreams', JSON.stringify(Array.from(favoritedStreams)));
|
||||
writeStored('favoritedStreams', Array.from(favoritedStreams));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user