From b8f57f34642764cc91bd259fcbf48292b1e8ff81 Mon Sep 17 00:00:00 2001 From: Jordan Aasen <166539328+jaasen-livefront@users.noreply.github.com> Date: Fri, 10 Jan 2025 10:00:57 -0800 Subject: [PATCH] [PM-12759] - Admin Console - Link to vault cipher is not opening cipher modal (#12738) * fix initial load emission race * prevent double dialog render * put logic back in place --- .../app/vault/org-vault/vault.component.ts | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/apps/web/src/app/vault/org-vault/vault.component.ts b/apps/web/src/app/vault/org-vault/vault.component.ts index 645d81cec1..14550968ba 100644 --- a/apps/web/src/app/vault/org-vault/vault.component.ts +++ b/apps/web/src/app/vault/org-vault/vault.component.ts @@ -32,7 +32,6 @@ import { switchMap, takeUntil, tap, - withLatestFrom, } from "rxjs/operators"; import { @@ -194,6 +193,7 @@ export class VaultComponent implements OnInit, OnDestroy { protected currentSearchText$: Observable; protected freeTrial$: Observable; protected resellerWarning$: Observable; + protected prevCipherId: string | null = null; /** * A list of collections that the user can assign items to and edit those items within. * @protected @@ -538,25 +538,26 @@ export class VaultComponent implements OnInit, OnDestroy { firstSetup$ .pipe( - switchMap(() => this.route.queryParams), - // Only process the queryParams if the dialog is not open (only when extension refresh is enabled) + switchMap(() => combineLatest([this.route.queryParams, allCipherMap$])), filter(() => this.vaultItemDialogRef == undefined || !this.extensionRefreshEnabled), - withLatestFrom(allCipherMap$, allCollections$, organization$), switchMap(async ([qParams, allCiphersMap]) => { const cipherId = getCipherIdFromParams(qParams); + if (!cipherId) { + this.prevCipherId = null; return; } - const cipher = allCiphersMap[cipherId]; + if (cipherId === this.prevCipherId) { + return; + } + + this.prevCipherId = cipherId; + + const cipher = allCiphersMap[cipherId]; if (cipher) { let action = qParams.action; - // Default to "view" if extension refresh is enabled - if (action == null && this.extensionRefreshEnabled) { - action = "view"; - } - if (action == "showFailedToDecrypt") { DecryptionFailureDialogComponent.open(this.dialogService, { cipherIds: [cipherId as CipherId], @@ -569,6 +570,11 @@ export class VaultComponent implements OnInit, OnDestroy { return; } + // Default to "view" if extension refresh is enabled + if (action == null && this.extensionRefreshEnabled) { + action = "view"; + } + if (action === "view") { await this.viewCipherById(cipher); } else {