From 669115227593f51a49415da7587481ccc63c48b0 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 28 Mar 2026 05:49:07 +0000 Subject: fix(cache): respect AniList media list recache windows --- src/stores/lastPruneTimes.ts | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/stores/lastPruneTimes.ts') 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(defaultTimes); let state: LastPruneTimes = defaultTimes; - - if (browser) - localforage.getItem("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") + .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, -- cgit v1.2.3