Wait for account to switch before proceeding (#9229)

This commit is contained in:
Matt Gibson 2024-05-17 14:47:21 -04:00 committed by GitHub
parent f97064effe
commit 7d29b3be13
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 0 deletions

View File

@ -1214,7 +1214,22 @@ export default class MainBackground {
);
// can be removed once password generation history is migrated to state providers
await this.stateService.clearDecryptedData(currentlyActiveAccount);
// HACK to ensure account is switched before proceeding
const switchPromise = firstValueFrom(
this.accountService.activeAccount$.pipe(
filter((account) => (account?.id ?? null) === (userId ?? null)),
timeout({
first: 1_000,
with: () => {
throw new Error(
"The account switch process did not complete in a reasonable amount of time.",
);
},
}),
),
);
await this.accountService.switchAccount(userId);
await switchPromise;
// Clear sequentialized caches
clearCaches();