1
0
mirror of https://github.com/bitwarden/browser synced 2026-01-30 16:23:53 +00:00

remove remaining checks for null folder id

This commit is contained in:
jaasen-livefront
2025-11-24 17:40:04 -08:00
parent 9122a8fd40
commit 90fce663a0
7 changed files with 10 additions and 14 deletions

View File

@@ -294,9 +294,7 @@ export class VaultFilterService implements VaultFilterServiceAbstraction {
// Otherwise, show only folders that have ciphers from the selected org and the "no folder" folder
const orgCiphers = ciphers.filter((c) => c.organizationId == org?.id);
return storedFolders.filter(
(f) => orgCiphers.some((oc) => oc.folderId == f.id) || f.id == null,
);
return storedFolders.filter((f) => orgCiphers.some((oc) => oc.folderId == f.id) || !f.id);
}
protected buildFolderTree(folders?: FolderView[]): TreeNode<FolderFilter> {

View File

@@ -87,7 +87,7 @@ export class RoutedVaultFilterBridge implements VaultFilter {
return this.legacyFilter.selectedFolderNode;
}
set selectedFolderNode(value: TreeNode<FolderFilter>) {
const folderId = value != null && value.node.id === null ? Unassigned : value?.node.id;
const folderId = value?.node.id ?? Unassigned;
this.bridgeService.navigate({
...this.routedFilter,
folderId,

View File

@@ -86,7 +86,7 @@ export class VaultFilterService implements DeprecatedVaultFilterServiceAbstracti
const ciphers = await this.cipherService.getAllDecrypted(userId);
const orgCiphers = ciphers.filter((c) => c.organizationId == organizationId);
folders = storedFolders.filter(
(f) => orgCiphers.some((oc) => oc.folderId == f.id) || f.id == null,
(f) => orgCiphers.some((oc) => oc.folderId == f.id) || !f.id,
);
}

View File

@@ -16,7 +16,6 @@ export class FolderView implements View, ITreeNodeObject {
}
this.id = f.id;
this.name = f.name.toString();
this.revisionDate = f.revisionDate;
}

View File

@@ -354,7 +354,7 @@ export class ImportComponent implements OnInit, OnDestroy, AfterViewInit {
switchMap((userId) => {
return this.folderService.folderViews$(userId);
}),
map((folders) => folders.filter((f) => f.id != null)),
map((folders) => folders.filter((f) => !!f.id)),
);
this.formGroup.controls.targetSelector.disable();

View File

@@ -4,12 +4,12 @@ import * as papa from "papaparse";
// This import has been flagged as unallowed for this class. It may be involved in a circular dependency loop.
// eslint-disable-next-line no-restricted-imports
import { Collection, CollectionView } from "@bitwarden/admin-console/common";
import { CollectionView } from "@bitwarden/admin-console/common";
import { normalizeExpiryYearFormat } from "@bitwarden/common/autofill/utils";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { ConsoleLogService } from "@bitwarden/common/platform/services/console-log.service";
import { OrganizationId } from "@bitwarden/common/types/guid";
import { CollectionId, OrganizationId } from "@bitwarden/common/types/guid";
import { FieldType, SecureNoteType, CipherType } from "@bitwarden/common/vault/enums";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
import { FieldView } from "@bitwarden/common/vault/models/view/field.view";
@@ -279,8 +279,7 @@ export abstract class BaseImporter {
const collection = new CollectionView({
name: f.name,
organizationId: this.organizationId,
// FIXME: Folder.id may be null, this should be changed when refactoring Folders to be ts-strict
id: Collection.isCollectionId(f.id) ? f.id : null,
id: f.id as CollectionId,
});
return collection;
});

View File

@@ -240,7 +240,7 @@ export class IndividualVaultExportService
};
folders.forEach((f) => {
if (f.id == null) {
if (!f.id) {
return;
}
const folder = new FolderWithIdExport();
@@ -268,7 +268,7 @@ export class IndividualVaultExportService
private buildCsvExport(decFolders: FolderView[], decCiphers: CipherView[]): string {
const foldersMap = new Map<string, FolderView>();
decFolders.forEach((f) => {
if (f.id != null) {
if (!f.id) {
foldersMap.set(f.id, f);
}
});
@@ -302,7 +302,7 @@ export class IndividualVaultExportService
};
decFolders.forEach((f) => {
if (f.id == null) {
if (!f.id) {
return;
}
const folder = new FolderWithIdExport();