1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 22:33:35 +00:00

[PM-329] Detangle SearchService & CipherService (#4838)

* Remove Circular Dependency

* Fix Vault Searching

* Remove Unused cipherServiceOptions

* Add searchService Parameter to CipherService

* Fix instantiation of CipherService in test
This commit is contained in:
Justin Baur
2023-04-07 11:11:20 -04:00
committed by GitHub
parent 36de1c8e32
commit 7263579eaf
20 changed files with 52 additions and 90 deletions

View File

@@ -1,4 +1,4 @@
import { Injector, LOCALE_ID, NgModule } from "@angular/core";
import { LOCALE_ID, NgModule } from "@angular/core";
import { AvatarUpdateService as AccountUpdateServiceAbstraction } from "@bitwarden/common/abstractions/account/avatar-update.service";
import { AnonymousHubService as AnonymousHubServiceAbstraction } from "@bitwarden/common/abstractions/anonymousHub.service";
@@ -251,7 +251,7 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
settingsService: SettingsServiceAbstraction,
apiService: ApiServiceAbstraction,
i18nService: I18nServiceAbstraction,
injector: Injector,
searchService: SearchServiceAbstraction,
stateService: StateServiceAbstraction,
encryptService: EncryptService,
fileUploadService: CipherFileUploadServiceAbstraction
@@ -261,7 +261,7 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
settingsService,
apiService,
i18nService,
() => injector.get(SearchServiceAbstraction),
searchService,
stateService,
encryptService,
fileUploadService
@@ -271,7 +271,7 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
SettingsServiceAbstraction,
ApiServiceAbstraction,
I18nServiceAbstraction,
Injector, // TODO: Get rid of this circular dependency!
SearchServiceAbstraction,
StateServiceAbstraction,
EncryptService,
CipherFileUploadServiceAbstraction,
@@ -475,7 +475,7 @@ import { AbstractThemingService } from "./theming/theming.service.abstraction";
{
provide: SearchServiceAbstraction,
useClass: SearchService,
deps: [CipherServiceAbstraction, LogService, I18nServiceAbstraction],
deps: [LogService, I18nServiceAbstraction],
},
{
provide: NotificationsServiceAbstraction,

View File

@@ -2,6 +2,7 @@ import { Directive, EventEmitter, Input, Output } from "@angular/core";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
@Directive()
@@ -31,7 +32,7 @@ export class VaultItemsComponent {
this._searchText = value;
}
constructor(protected searchService: SearchService) {}
constructor(protected searchService: SearchService, protected cipherService: CipherService) {}
async load(filter: (cipher: CipherView) => boolean = null, deleted = false) {
this.deleted = deleted ?? false;
@@ -92,6 +93,7 @@ export class VaultItemsComponent {
protected deletedFilter: (cipher: CipherView) => boolean = (c) => c.isDeleted === this.deleted;
protected async doSearch(indexedCiphers?: CipherView[]) {
indexedCiphers = indexedCiphers ?? (await this.cipherService.getAllDecrypted());
this.ciphers = await this.searchService.searchCiphers(
this.searchText,
[this.filter, this.deletedFilter],