1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-27 04:03:00 +02:00

Wait for account to switch before proceeding (#9229)

(cherry picked from commit 7d29b3be13)
This commit is contained in:
Matt Gibson 2024-05-17 14:47:21 -04:00
parent 184f22fbbc
commit 89ea90ce51
No known key found for this signature in database
GPG Key ID: 963EE038B0581878

View File

@ -1190,7 +1190,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();