Skip to content

Commit

Permalink
Remove the 15-second window where you can't refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis committed Jan 26, 2025
1 parent d6e8fd0 commit 0e58dff
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions src/app/inventory/d2-stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,6 @@ export function loadStores(): ThunkResult<DimStore[] | undefined> {
};
}

/** 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

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0e58dff

Please sign in to comment.