mirror of
https://github.com/bitwarden/browser.git
synced 2024-10-24 08:09:59 +02:00
Remove old code
This commit is contained in:
parent
6dea30e8f4
commit
897d7a5266
@ -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<Record<OrganizationId, OrgKey> | null>;
|
||||
let cryptoKeys: ReplaySubject<Record<OrganizationId, OrgKey> | 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
|
||||
|
@ -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<CollectionId, CollectionData>
|
||||
>;
|
||||
/**
|
||||
* @deprecated use decryptedCollectionState instead
|
||||
*/
|
||||
private activeUserDecryptedCollectionDataState: DerivedState<CollectionView[]>;
|
||||
|
||||
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<UserId>) {
|
||||
return userId$.pipe(
|
||||
|
Loading…
Reference in New Issue
Block a user