diff options
| author | Fuwn <[email protected]> | 2026-03-28 05:49:07 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-03-28 05:49:07 +0000 |
| commit | 669115227593f51a49415da7587481ccc63c48b0 (patch) | |
| tree | 5fa7b93d7b7fabe9a3adc9c3bad8603e6bdb9070 /src/stores/lastPruneTimes.ts | |
| parent | feat(manga): allow forcing automatic refresh (diff) | |
| download | due.moe-669115227593f51a49415da7587481ccc63c48b0.tar.xz due.moe-669115227593f51a49415da7587481ccc63c48b0.zip | |
fix(cache): respect AniList media list recache windows
Diffstat (limited to 'src/stores/lastPruneTimes.ts')
| -rw-r--r-- | src/stores/lastPruneTimes.ts | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/stores/lastPruneTimes.ts b/src/stores/lastPruneTimes.ts index 4741201e..2a770538 100644 --- a/src/stores/lastPruneTimes.ts +++ b/src/stores/lastPruneTimes.ts @@ -17,22 +17,29 @@ const defaultTimes: LastPruneTimes = { const createStore = () => { const store = writable<LastPruneTimes>(defaultTimes); let state: LastPruneTimes = defaultTimes; - - if (browser) - localforage.getItem<LastPruneTimes>("lastPruneTimes").then((value) => { - if ( - value && - Object.keys(value).length === Object.keys(defaultTimes).length - ) - store.set(value); - }); + let hydrated = !browser; store.subscribe((value) => { state = value; - if (browser) localforage.setItem("lastPruneTimes", value); + if (browser && hydrated) localforage.setItem("lastPruneTimes", value); }); + if (browser) + localforage + .getItem<LastPruneTimes>("lastPruneTimes") + .then(async (value) => { + if ( + value && + Object.keys(value).length === Object.keys(defaultTimes).length + ) + store.set(value); + + hydrated = true; + + await localforage.setItem("lastPruneTimes", state); + }); + return { subscribe: store.subscribe, set: store.set, |