From f57cb83d460d746fc7802a28ad4cb20fb5af408d Mon Sep 17 00:00:00 2001 From: Leslie Xiong Date: Fri, 23 Jan 2026 10:55:41 -0500 Subject: [PATCH] [BUG FIX]Desktop/Pm 31148/Pm 31149/Unexpected behaviors for Collections and Folders (#18506) * fixed collections still appearing if all orgs are suspended * fixed 'No folders' not displaying vault items * PR followup: - converted `allOrganizationsDisabled` to computed property - converted observables to signals --- .../vault-filter/vault-filter.component.html | 8 ++-- .../vault-filter/vault-filter.component.ts | 38 ++++++++++--------- .../src/vault/app/vault-v3/vault.component.ts | 2 + 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.html b/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.html index e0ae4687ed8..2110c545d9e 100644 --- a/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.html +++ b/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.html @@ -6,11 +6,11 @@ - + @if (showCollectionsFilter()) { - @for (collection of (collections$ | async)?.children ?? []; track collection.node.id) { + @for (collection of collections()?.children ?? []; track collection.node.id) { } @@ -32,7 +32,7 @@ [appA11yTitle]="'folders' | i18n" [disableToggleOnClick]="true" > - @for (folder of (folders$ | async)?.children ?? []; track folder.node.id) { + @for (folder of folders()?.children ?? []; track folder.node.id) { >; - protected collections$: Observable>; - protected folders$: Observable>; - protected cipherTypes$: Observable>; + protected readonly organizations = toSignal(this.vaultFilterService.organizationTree$); + protected readonly collections = toSignal(this.vaultFilterService.collectionTree$); + protected readonly folders = toSignal(this.vaultFilterService.folderTree$); + protected readonly cipherTypes = toSignal(this.vaultFilterService.cipherTypeTree$); protected readonly showCollectionsFilter = computed(() => { - return this.organizations$ != null && !this.activeFilter()?.isMyVaultSelected; + return ( + this.organizations() != null && + !this.activeFilter()?.isMyVaultSelected && + !this.allOrganizationsDisabled() + ); + }); + + protected readonly allOrganizationsDisabled = computed(() => { + if (!this.organizations()) { + return false; + } + const orgs = this.organizations().children.filter((org) => org.node.id !== "MyVault"); + return orgs.length > 0 && orgs.every((org) => !org.node.enabled); }); private async setActivePolicies() { @@ -98,16 +107,9 @@ export class VaultFilterComponent implements OnInit { async ngOnInit(): Promise { this.activeUserId = await firstValueFrom(this.accountService.activeAccount$.pipe(getUserId)); - this.organizations$ = this.vaultFilterService.organizationTree$; - if ( - this.organizations$ != null && - (await firstValueFrom(this.organizations$)).children.length > 0 - ) { + if (this.organizations() != null && this.organizations().children.length > 0) { await this.setActivePolicies(); } - this.cipherTypes$ = this.vaultFilterService.cipherTypeTree$; - this.folders$ = this.vaultFilterService.folderTree$; - this.collections$ = this.vaultFilterService.collectionTree$; this.showArchiveVaultFilter = await firstValueFrom( this.cipherArchiveService.hasArchiveFlagEnabled$, diff --git a/apps/desktop/src/vault/app/vault-v3/vault.component.ts b/apps/desktop/src/vault/app/vault-v3/vault.component.ts index a64830c3b5d..455f9177c4d 100644 --- a/apps/desktop/src/vault/app/vault-v3/vault.component.ts +++ b/apps/desktop/src/vault/app/vault-v3/vault.component.ts @@ -805,6 +805,8 @@ export class VaultComponent implements OnInit, OnDestroy, CopyClickListener { type: CipherViewLikeUtils.getType(cipher), // Normalize undefined organizationId to null for filter compatibility organizationId: cipher.organizationId ?? null, + // Normalize empty string folderId to null for filter compatibility + folderId: cipher.folderId ? cipher.folderId : null, // Explicitly include isDeleted and isArchived since they might be getters isDeleted: CipherViewLikeUtils.isDeleted(cipher), isArchived: CipherViewLikeUtils.isArchived(cipher),