diff --git a/src/background.ts b/src/background.ts index 50a11cb..95edc51 100644 --- a/src/background.ts +++ b/src/background.ts @@ -329,6 +329,20 @@ chrome.storage.onChanged.addListener((changes, area) => { async function refreshAccountStates(): Promise { console.debug('[substandard] session changed; refreshing subscription and block state') + // Started here and awaited at the end, so a sign-in is what pays for the + // walk instead of the first popup after it — but kept out of the badge work + // below, because no icon should wait on a read this long. + // + // Not a refresh, unlike the two reads below. Those must show the new + // account's own actions, so they re-read; the follow set is keyed by DID, so + // a new account is already a new entry, and asking for a refresh here would + // mean re-walking fifty thousand follows every time a handle or an avatar + // changed — `refreshStoredSession` rewrites the mirror for those too. + const warm = getFollows(false).catch((err: unknown) => { + console.debug('[substandard] could not warm the follow set', err) + return null + }) + const all = await chrome.storage.session.get(null) const [subs, blocks] = await Promise.all([ getSubscriptions(true).catch(() => null), @@ -342,4 +356,6 @@ async function refreshAccountStates(): Promise { state.blocked = blocks ? blocks.dids.includes(state.pub.did) : undefined await setTabState(Number(key.slice(4)), state) } + // Keeps the worker alive for the walk; the listener is what holds it open. + await warm }