aboutsummaryrefslogtreecommitdiff
path: root/src/stores
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-06-11 23:32:39 -0700
committerFuwn <[email protected]>2025-06-11 23:32:39 -0700
commitb288ea46b769f407b25e18586dbd2fb36626cfb3 (patch)
tree0747708aa27eafacdf93427f8eb2b7ad78ae428d /src/stores
parentfix(stores): Move anime and manga from localStorage to IndexedDB (diff)
downloaddue.moe-b288ea46b769f407b25e18586dbd2fb36626cfb3.tar.xz
due.moe-b288ea46b769f407b25e18586dbd2fb36626cfb3.zip
refactor(stores): Generic persistent storage facility
Diffstat (limited to 'src/stores')
-rw-r--r--src/stores/anime.ts16
-rw-r--r--src/stores/manga.ts16
2 files changed, 4 insertions, 28 deletions
diff --git a/src/stores/anime.ts b/src/stores/anime.ts
index dd85588d..116139a3 100644
--- a/src/stores/anime.ts
+++ b/src/stores/anime.ts
@@ -1,17 +1,5 @@
-import { browser } from '$app/environment';
-import { writable } from 'svelte/store';
-import localforage from 'localforage';
+import { persistentStore } from '$lib/Utility/persistentStore';
-const anime = writable<string>('');
-
-if (browser) {
- localforage.getItem<string>('anime').then((value) => {
- if (value) anime.set(value);
- });
-
- anime.subscribe((value) => {
- localforage.setItem('anime', value);
- });
-}
+const anime = persistentStore<string>('anime', '');
export default anime;
diff --git a/src/stores/manga.ts b/src/stores/manga.ts
index ff61d335..84b19665 100644
--- a/src/stores/manga.ts
+++ b/src/stores/manga.ts
@@ -1,17 +1,5 @@
-import { browser } from '$app/environment';
-import { writable } from 'svelte/store';
-import localforage from 'localforage';
+import { persistentStore } from '$lib/Utility/persistentStore';
-const manga = writable<string>('');
-
-if (browser) {
- localforage.getItem<string>('manga').then((value) => {
- if (value) manga.set(value);
- });
-
- manga.subscribe((value) => {
- localforage.setItem('manga', value);
- });
-}
+const manga = persistentStore<string>('manga', '');
export default manga;