1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 17:53:39 +00:00

[PM-6797] Prevent account switching race condition on desktop & enable worker decryption (#9312)

* Prevent account switching race condition on desktop

This enables us to allow background thread / multithread bulk decryption on desktop.

* Disable account switcher component during switching
This commit is contained in:
Bernd Schoolmann
2024-07-11 14:11:51 +02:00
committed by GitHub
parent f03dabb6d6
commit e977dacdcf
7 changed files with 22 additions and 26 deletions

View File

@@ -7,6 +7,7 @@
cdkOverlayOrigin
#trigger="cdkOverlayOrigin"
[hidden]="!view.showSwitcher"
[disabled]="disabled"
aria-haspopup="dialog"
>
<ng-container *ngIf="view.activeAccount; else noActiveAccount">

View File

@@ -12,6 +12,7 @@ import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authenticatio
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { CommandDefinition, MessageListener } from "@bitwarden/common/platform/messaging";
import { UserId } from "@bitwarden/common/types/guid";
type ActiveAccount = {
@@ -75,12 +76,14 @@ export class AccountSwitcherComponent {
showSwitcher$: Observable<boolean>;
numberOfAccounts$: Observable<number>;
disabled = false;
constructor(
private stateService: StateService,
private authService: AuthService,
private avatarService: AvatarService,
private messagingService: MessagingService,
private messageListener: MessageListener,
private router: Router,
private environmentService: EnvironmentService,
private loginEmailService: LoginEmailServiceAbstraction,
@@ -159,7 +162,13 @@ export class AccountSwitcherComponent {
async switch(userId: string) {
this.close();
this.messagingService.send("switchAccount", { userId: userId });
this.disabled = true;
const accountSwitchFinishedPromise = firstValueFrom(
this.messageListener.messages$(new CommandDefinition("finishSwitchAccount")),
);
this.messagingService.send("switchAccount", { userId });
await accountSwitchFinishedPromise;
this.disabled = false;
}
async addAccount() {