diff options
| author | Fuwn <[email protected]> | 2025-06-11 23:27:13 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-06-11 23:27:13 -0700 |
| commit | 0e78835a9a129df4517ed504eec4bd2fa84f0cd4 (patch) | |
| tree | 32c74f9934ccf6f0d876c368d4b436a48dcc7d95 /src | |
| parent | deps: Update all applicable dependencies (diff) | |
| download | due.moe-0e78835a9a129df4517ed504eec4bd2fa84f0cd4.tar.xz due.moe-0e78835a9a129df4517ed504eec4bd2fa84f0cd4.zip | |
fix(stores): Move anime and manga from localStorage to IndexedDB
Diffstat (limited to 'src')
| -rw-r--r-- | src/stores/anime.ts | 15 | ||||
| -rw-r--r-- | src/stores/manga.ts | 15 |
2 files changed, 22 insertions, 8 deletions
diff --git a/src/stores/anime.ts b/src/stores/anime.ts index f9b649a0..dd85588d 100644 --- a/src/stores/anime.ts +++ b/src/stores/anime.ts @@ -1,10 +1,17 @@ import { browser } from '$app/environment'; import { writable } from 'svelte/store'; +import localforage from 'localforage'; -const anime = writable<string>(browser ? localStorage.getItem('anime') ?? '' : ''); +const anime = writable<string>(''); -anime.subscribe((value) => { - if (browser) localStorage.setItem('anime', value); -}); +if (browser) { + localforage.getItem<string>('anime').then((value) => { + if (value) anime.set(value); + }); + + anime.subscribe((value) => { + localforage.setItem('anime', value); + }); +} export default anime; diff --git a/src/stores/manga.ts b/src/stores/manga.ts index 24bc9ce1..ff61d335 100644 --- a/src/stores/manga.ts +++ b/src/stores/manga.ts @@ -1,10 +1,17 @@ import { browser } from '$app/environment'; import { writable } from 'svelte/store'; +import localforage from 'localforage'; -const manga = writable<string>(browser ? localStorage.getItem('manga') ?? '' : ''); +const manga = writable<string>(''); -manga.subscribe((value) => { - if (browser) localStorage.setItem('manga', value); -}); +if (browser) { + localforage.getItem<string>('manga').then((value) => { + if (value) manga.set(value); + }); + + manga.subscribe((value) => { + localforage.setItem('manga', value); + }); +} export default manga; |