From 897d7a5266942929af23e6f85908488dc919ce78 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Thu, 24 Oct 2024 14:32:21 +1000 Subject: [PATCH] Remove old code --- .../default-collection-vNext.service.spec.ts | 8 ++--- .../default-collection-vNext.service.ts | 32 ++----------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/libs/admin-console/src/common/collections/services/default-collection-vNext.service.spec.ts b/libs/admin-console/src/common/collections/services/default-collection-vNext.service.spec.ts index e930ca63d0..d6650b385a 100644 --- a/libs/admin-console/src/common/collections/services/default-collection-vNext.service.spec.ts +++ b/libs/admin-console/src/common/collections/services/default-collection-vNext.service.spec.ts @@ -1,5 +1,5 @@ import { mock, MockProxy } from "jest-mock-extended"; -import { firstValueFrom, of, Subject } from "rxjs"; +import { firstValueFrom, of, ReplaySubject } from "rxjs"; import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service"; import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; @@ -30,7 +30,7 @@ describe("DefaultCollectionService", () => { let userId: UserId; - let cryptoKeys: Subject | null>; + let cryptoKeys: ReplaySubject | null>; let collectionService: DefaultCollectionvNextService; @@ -42,8 +42,8 @@ describe("DefaultCollectionService", () => { i18nService = mock(); stateProvider = new FakeStateProvider(mockAccountServiceWith(userId)); - cryptoKeys = new Subject(); - cryptoService.orgKeys$.calledWith(userId).mockReturnValue(cryptoKeys); + cryptoKeys = new ReplaySubject(1); + cryptoService.orgKeys$.mockReturnValue(cryptoKeys); // Set up mock decryption encryptService.decryptToUtf8 diff --git a/libs/admin-console/src/common/collections/services/default-collection-vNext.service.ts b/libs/admin-console/src/common/collections/services/default-collection-vNext.service.ts index 6c29ef8776..503dc25ff7 100644 --- a/libs/admin-console/src/common/collections/services/default-collection-vNext.service.ts +++ b/libs/admin-console/src/common/collections/services/default-collection-vNext.service.ts @@ -4,7 +4,7 @@ import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.se import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { Utils } from "@bitwarden/common/platform/misc/utils"; -import { ActiveUserState, StateProvider, DerivedState } from "@bitwarden/common/platform/state"; +import { StateProvider, DerivedState } from "@bitwarden/common/platform/state"; import { CollectionId, OrganizationId, UserId } from "@bitwarden/common/types/guid"; import { OrgKey } from "@bitwarden/common/types/key"; import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node"; @@ -21,40 +21,12 @@ import { const NestingDelimiter = "/"; export class DefaultCollectionvNextService implements CollectionvNextService { - /** - * @deprecated use encryptedCollectionState instead - */ - private activeUserEncryptedCollectionDataState: ActiveUserState< - Record - >; - /** - * @deprecated use decryptedCollectionState instead - */ - private activeUserDecryptedCollectionDataState: DerivedState; - constructor( private cryptoService: CryptoService, private encryptService: EncryptService, private i18nService: I18nService, protected stateProvider: StateProvider, - ) { - this.activeUserEncryptedCollectionDataState = this.stateProvider.getActive( - ENCRYPTED_COLLECTION_DATA_KEY, - ); - - const encryptedCollectionsWithKeys = - this.activeUserEncryptedCollectionDataState.combinedState$.pipe( - switchMap(([userId, collectionData]) => - combineLatest([of(collectionData), this.cryptoService.orgKeys$(userId)]), - ), - ); - - this.activeUserDecryptedCollectionDataState = this.stateProvider.getDerived( - encryptedCollectionsWithKeys, - DECRYPTED_COLLECTION_DATA_KEY, - { collectionService: this }, - ); - } + ) {} encryptedCollections$(userId$: Observable) { return userId$.pipe(