From c47194b21cc6cbb459af95a7f69b1c7ca42ea5e9 Mon Sep 17 00:00:00 2001 From: Matt Gibson Date: Thu, 20 Apr 2023 13:46:03 -0400 Subject: [PATCH] Lock active account first (#5241) Locking all non-active accounts prior to active lead to process reload issues. Remove unnecessary routing Prefer Record keys to deep Account object value Await promises --- apps/desktop/src/app/app.component.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/desktop/src/app/app.component.ts b/apps/desktop/src/app/app.component.ts index 0f1c2ae583..9862c58815 100644 --- a/apps/desktop/src/app/app.component.ts +++ b/apps/desktop/src/app/app.component.ts @@ -180,13 +180,17 @@ export class AppComponent implements OnInit, OnDestroy { case "lockVault": await this.vaultTimeoutService.lock(message.userId); break; - case "lockAllVaults": - for (const userId in await firstValueFrom(this.stateService.accounts$)) { - if (userId != null) { - await this.vaultTimeoutService.lock(userId); - } - } + case "lockAllVaults": { + const currentUser = await this.stateService.getUserId(); + const accounts = await firstValueFrom(this.stateService.accounts$); + await this.vaultTimeoutService.lock(currentUser); + Promise.all( + Object.keys(accounts) + .filter((u) => u !== currentUser) + .map((u) => this.vaultTimeoutService.lock(u)) + ); break; + } case "locked": this.modalService.closeAll(); if (