From 0e58dff4e98e66722cb364c2dd578a35c1a99197 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sat, 25 Jan 2025 16:10:05 -0800 Subject: [PATCH] Remove the 15-second window where you can't refresh --- src/app/inventory/d2-stores.ts | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/app/inventory/d2-stores.ts b/src/app/inventory/d2-stores.ts index dec718194..acf815ad2 100644 --- a/src/app/inventory/d2-stores.ts +++ b/src/app/inventory/d2-stores.ts @@ -135,8 +135,6 @@ export function loadStores(): ThunkResult { }; } -/** time in milliseconds after which we could expect Bnet to return an updated response */ -const BUNGIE_CACHE_TTL = 15_000; /** How old the profile can be and still trigger cleanup of tags. */ const FRESH_ENOUGH_TO_CLEAN_INFOS = 90_000; // 90 seconds @@ -187,22 +185,9 @@ function loadProfile( } } - let cachedProfileMintedDate = new Date(0); - - // If our cached profile is up to date - if (cachedProfileResponse) { - // TODO: need to make sure we still load at the right frequency / for manual cache busts? - cachedProfileMintedDate = new Date(cachedProfileResponse.responseMintedTimestamp ?? 0); - const profileAge = Date.now() - cachedProfileMintedDate.getTime(); - if (!storesLoadedSelector(getState()) && profileAge > 0 && profileAge < BUNGIE_CACHE_TTL) { - warnLog( - TAG, - `Cached profile is only ${profileAge / 1000}s old, skipping remote load.`, - profileAge, - ); - return { profile: cachedProfileResponse, live: false }; - } - } + const cachedProfileMintedDate = cachedProfileResponse + ? new Date(cachedProfileResponse.responseMintedTimestamp ?? 0) + : new Date(0); try { const remoteProfileResponse = await getStores(account);