mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-21 11:35:34 +01:00
Wait for account to switch before proceeding (#9229)
This commit is contained in:
parent
f97064effe
commit
7d29b3be13
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user