From 37c333089760bcda9107167b3070ed96afb450a6 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Wed, 20 Sep 2023 09:40:57 -0700 Subject: [PATCH] fix: wait to fetch lists until rehydration (#7332) --- src/state/lists/updater.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/state/lists/updater.ts b/src/state/lists/updater.ts index 655aed67d8..9952c8cadb 100644 --- a/src/state/lists/updater.ts +++ b/src/state/lists/updater.ts @@ -41,18 +41,16 @@ export default function Updater(): null { // fetch all lists every 10 minutes, but only after we initialize provider useInterval(fetchAllListsCallback, provider ? ms(`10m`) : null) - // whenever a list is not loaded and not loading, try again to load it useEffect(() => { + if (!rehydrated) return // loaded lists will not be available until state is rehydrated + + // whenever a list is not loaded and not loading, try again to load it Object.keys(lists).forEach((listUrl) => { const list = lists[listUrl] if (!list.current && !list.loadingRequestId && !list.error) { fetchList(listUrl).catch((error) => console.debug('list added fetching error', error)) } }) - }, [dispatch, fetchList, lists]) - - // if any lists from unsupported lists are loaded, check them too (in case new updates since last visit) - useEffect(() => { UNSUPPORTED_LIST_URLS.forEach((listUrl) => { const list = lists[listUrl] if (!list || (!list.current && !list.loadingRequestId && !list.error)) { @@ -61,7 +59,7 @@ export default function Updater(): null { ) } }) - }, [dispatch, fetchList, lists]) + }, [dispatch, fetchList, lists, rehydrated]) // automatically update lists if versions are minor/patch useEffect(() => {