mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 19:23:52 +00:00
[PM-6194] Refactor injection of services in browser services module (#8380)
* refactored injector of services on the browser service module * refactored the search and popup serach service to use state provider * renamed back to default * removed token service that was readded during merge conflict * Updated search service construction on the cli * updated to use user key definition * Reafctored all components that refernce issearchable * removed commented variable * added uncommited code to remove dependencies not needed anymore * added uncommited code to remove dependencies not needed anymore
This commit is contained in:
@@ -514,7 +514,7 @@ export default class MainBackground {
|
||||
this.apiService,
|
||||
this.fileUploadService,
|
||||
);
|
||||
this.searchService = new SearchService(this.logService, this.i18nService);
|
||||
this.searchService = new SearchService(this.logService, this.i18nService, this.stateProvider);
|
||||
|
||||
this.collectionService = new CollectionService(
|
||||
this.cryptoService,
|
||||
@@ -1177,7 +1177,7 @@ export default class MainBackground {
|
||||
const newActiveUser = await this.stateService.clean({ userId: userId });
|
||||
|
||||
if (userId == null || userId === currentUserId) {
|
||||
this.searchService.clearIndex();
|
||||
await this.searchService.clearIndex();
|
||||
}
|
||||
|
||||
await this.stateEventRunnerService.handleEvent("logout", currentUserId as UserId);
|
||||
|
||||
@@ -14,12 +14,17 @@ import {
|
||||
logServiceFactory,
|
||||
LogServiceInitOptions,
|
||||
} from "../../platform/background/service-factories/log-service.factory";
|
||||
import {
|
||||
stateProviderFactory,
|
||||
StateProviderInitOptions,
|
||||
} from "../../platform/background/service-factories/state-provider.factory";
|
||||
|
||||
type SearchServiceFactoryOptions = FactoryOptions;
|
||||
|
||||
export type SearchServiceInitOptions = SearchServiceFactoryOptions &
|
||||
LogServiceInitOptions &
|
||||
I18nServiceInitOptions;
|
||||
I18nServiceInitOptions &
|
||||
StateProviderInitOptions;
|
||||
|
||||
export function searchServiceFactory(
|
||||
cache: { searchService?: AbstractSearchService } & CachedServices,
|
||||
@@ -33,6 +38,7 @@ export function searchServiceFactory(
|
||||
new SearchService(
|
||||
await logServiceFactory(cache, opts),
|
||||
await i18nServiceFactory(cache, opts),
|
||||
await stateProviderFactory(cache, opts),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
||||
import { StateProvider } from "@bitwarden/common/platform/state";
|
||||
import { SearchService } from "@bitwarden/common/services/search.service";
|
||||
|
||||
export class PopupSearchService extends SearchService {
|
||||
constructor(
|
||||
private mainSearchService: SearchService,
|
||||
logService: LogService,
|
||||
i18nService: I18nService,
|
||||
) {
|
||||
super(logService, i18nService);
|
||||
constructor(logService: LogService, i18nService: I18nService, stateProvider: StateProvider) {
|
||||
super(logService, i18nService, stateProvider);
|
||||
}
|
||||
|
||||
clearIndex() {
|
||||
clearIndex(): Promise<void> {
|
||||
throw new Error("Not available.");
|
||||
}
|
||||
|
||||
@@ -19,7 +16,7 @@ export class PopupSearchService extends SearchService {
|
||||
throw new Error("Not available.");
|
||||
}
|
||||
|
||||
getIndexForSearch() {
|
||||
return this.mainSearchService.getIndexForSearch();
|
||||
async getIndexForSearch() {
|
||||
return await super.getIndexForSearch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,17 +74,15 @@ import {
|
||||
GlobalStateProvider,
|
||||
StateProvider,
|
||||
} from "@bitwarden/common/platform/state";
|
||||
import { SearchService } from "@bitwarden/common/services/search.service";
|
||||
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
|
||||
import { UsernameGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/username";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { CollectionService } from "@bitwarden/common/vault/abstractions/collection.service";
|
||||
import { CipherFileUploadService } from "@bitwarden/common/vault/abstractions/file-upload/cipher-file-upload.service";
|
||||
import { FolderService as FolderServiceAbstraction } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
|
||||
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||
import { TotpService } from "@bitwarden/common/vault/services/totp.service";
|
||||
import { DialogService } from "@bitwarden/components";
|
||||
import { VaultExportServiceAbstraction } from "@bitwarden/vault-export-core";
|
||||
|
||||
import { UnauthGuardService } from "../../auth/popup/services";
|
||||
import { AutofillService as AutofillServiceAbstraction } from "../../autofill/services/abstractions/autofill.service";
|
||||
@@ -187,19 +185,8 @@ const safeProviders: SafeProvider[] = [
|
||||
}),
|
||||
safeProvider({
|
||||
provide: SearchServiceAbstraction,
|
||||
useFactory: (logService: LogService, i18nService: I18nServiceAbstraction) => {
|
||||
return new PopupSearchService(
|
||||
getBgService<SearchService>("searchService")(),
|
||||
logService,
|
||||
i18nService,
|
||||
);
|
||||
},
|
||||
deps: [LogService, I18nServiceAbstraction],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: CipherFileUploadService,
|
||||
useFactory: getBgService<CipherFileUploadService>("cipherFileUploadService"),
|
||||
deps: [],
|
||||
useClass: PopupSearchService,
|
||||
deps: [LogService, I18nServiceAbstraction, StateProvider],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: CipherService,
|
||||
@@ -231,11 +218,6 @@ const safeProviders: SafeProvider[] = [
|
||||
useClass: BrowserEnvironmentService,
|
||||
deps: [LogService, StateProvider, AccountServiceAbstraction],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: TotpService,
|
||||
useFactory: getBgService<TotpService>("totpService"),
|
||||
deps: [],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: I18nServiceAbstraction,
|
||||
useFactory: (globalStateProvider: GlobalStateProvider) => {
|
||||
@@ -252,6 +234,11 @@ const safeProviders: SafeProvider[] = [
|
||||
},
|
||||
deps: [EncryptService],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: TotpServiceAbstraction,
|
||||
useClass: TotpService,
|
||||
deps: [CryptoFunctionService, LogService],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: AuthRequestServiceAbstraction,
|
||||
useFactory: getBgService<AuthRequestServiceAbstraction>("authRequestService"),
|
||||
@@ -333,11 +320,6 @@ const safeProviders: SafeProvider[] = [
|
||||
BillingAccountProfileStateService,
|
||||
],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: VaultExportServiceAbstraction,
|
||||
useFactory: getBgService<VaultExportServiceAbstraction>("exportService"),
|
||||
deps: [],
|
||||
}),
|
||||
safeProvider({
|
||||
provide: KeyConnectorService,
|
||||
useFactory: getBgService<KeyConnectorService>("keyConnectorService"),
|
||||
|
||||
@@ -171,9 +171,7 @@ export class SendGroupingsComponent extends BaseSendComponent {
|
||||
}
|
||||
|
||||
showSearching() {
|
||||
return (
|
||||
this.hasSearched || (!this.searchPending && this.searchService.isSearchable(this.searchText))
|
||||
);
|
||||
return this.hasSearched || (!this.searchPending && this.isSearchable);
|
||||
}
|
||||
|
||||
private calculateTypeCounts() {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abs
|
||||
import { EventType } from "@bitwarden/common/enums";
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||
import { CipherRepromptType } from "@bitwarden/common/vault/enums/cipher-reprompt-type";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
@@ -31,7 +31,7 @@ export class ActionButtonsComponent implements OnInit, OnDestroy {
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private eventCollectionService: EventCollectionService,
|
||||
private totpService: TotpService,
|
||||
private totpService: TotpServiceAbstraction,
|
||||
private passwordRepromptService: PasswordRepromptService,
|
||||
private billingAccountProfileStateService: BillingAccountProfileStateService,
|
||||
) {}
|
||||
|
||||
@@ -311,7 +311,7 @@ export class Fido2Component implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
protected async search() {
|
||||
this.hasSearched = this.searchService.isSearchable(this.searchText);
|
||||
this.hasSearched = await this.searchService.isSearchable(this.searchText);
|
||||
this.searchPending = true;
|
||||
if (this.hasSearched) {
|
||||
this.displayedCiphers = await this.searchService.searchCiphers(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit } from "@angular/core";
|
||||
import { Router } from "@angular/router";
|
||||
import { Subject, firstValueFrom } from "rxjs";
|
||||
import { debounceTime, takeUntil } from "rxjs/operators";
|
||||
import { Subject, firstValueFrom, from } from "rxjs";
|
||||
import { debounceTime, switchMap, takeUntil } from "rxjs/operators";
|
||||
|
||||
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
@@ -120,8 +120,14 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
this.search$
|
||||
.pipe(debounceTime(500), takeUntil(this.destroy$))
|
||||
.subscribe(() => this.searchVault());
|
||||
.pipe(
|
||||
debounceTime(500),
|
||||
switchMap(() => {
|
||||
return from(this.searchVault());
|
||||
}),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
const autofillOnPageLoadOrgPolicy = await firstValueFrom(
|
||||
this.autofillSettingsService.activateAutofillOnPageLoadFromPolicy$,
|
||||
@@ -232,14 +238,12 @@ export class CurrentTabComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
searchVault() {
|
||||
if (!this.searchService.isSearchable(this.searchText)) {
|
||||
async searchVault() {
|
||||
if (!(await this.searchService.isSearchable(this.searchText))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.router.navigate(["/tabs/vault"], { queryParams: { searchText: this.searchText } });
|
||||
await this.router.navigate(["/tabs/vault"], { queryParams: { searchText: this.searchText } });
|
||||
}
|
||||
|
||||
closeOnEsc(e: KeyboardEvent) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Location } from "@angular/common";
|
||||
import { ChangeDetectorRef, Component, NgZone, OnDestroy, OnInit } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
import { first } from "rxjs/operators";
|
||||
import { BehaviorSubject, Subject, firstValueFrom, from } from "rxjs";
|
||||
import { first, switchMap, takeUntil } from "rxjs/operators";
|
||||
|
||||
import { VaultFilter } from "@bitwarden/angular/vault/vault-filter/models/vault-filter.model";
|
||||
import { SearchService } from "@bitwarden/common/abstractions/search.service";
|
||||
@@ -53,7 +53,6 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
folderCounts = new Map<string, number>();
|
||||
collectionCounts = new Map<string, number>();
|
||||
typeCounts = new Map<CipherType, number>();
|
||||
searchText: string;
|
||||
state: BrowserGroupingsComponentState;
|
||||
showLeftHeader = true;
|
||||
searchPending = false;
|
||||
@@ -71,6 +70,16 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
private hasSearched = false;
|
||||
private hasLoadedAllCiphers = false;
|
||||
private allCiphers: CipherView[] = null;
|
||||
private destroy$ = new Subject<void>();
|
||||
private _searchText$ = new BehaviorSubject<string>("");
|
||||
private isSearchable: boolean = false;
|
||||
|
||||
get searchText() {
|
||||
return this._searchText$.value;
|
||||
}
|
||||
set searchText(value: string) {
|
||||
this._searchText$.next(value);
|
||||
}
|
||||
|
||||
constructor(
|
||||
private i18nService: I18nService,
|
||||
@@ -148,6 +157,15 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
BrowserPopupUtils.setContentScrollY(window, this.state?.scrollY);
|
||||
}
|
||||
});
|
||||
|
||||
this._searchText$
|
||||
.pipe(
|
||||
switchMap((searchText) => from(this.searchService.isSearchable(searchText))),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe((isSearchable) => {
|
||||
this.isSearchable = isSearchable;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -161,6 +179,8 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.saveState();
|
||||
this.broadcasterService.unsubscribe(ComponentId);
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
async load() {
|
||||
@@ -181,7 +201,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
async loadCiphers() {
|
||||
this.allCiphers = await this.cipherService.getAllDecrypted();
|
||||
if (!this.hasLoadedAllCiphers) {
|
||||
this.hasLoadedAllCiphers = !this.searchService.isSearchable(this.searchText);
|
||||
this.hasLoadedAllCiphers = !(await this.searchService.isSearchable(this.searchText));
|
||||
}
|
||||
await this.search(null);
|
||||
this.getCounts();
|
||||
@@ -210,7 +230,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
const filterDeleted = (c: CipherView) => !c.isDeleted;
|
||||
if (timeout == null) {
|
||||
this.hasSearched = this.searchService.isSearchable(this.searchText);
|
||||
this.hasSearched = this.isSearchable;
|
||||
this.ciphers = await this.searchService.searchCiphers(
|
||||
this.searchText,
|
||||
filterDeleted,
|
||||
@@ -223,7 +243,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
this.searchPending = true;
|
||||
this.searchTimeout = setTimeout(async () => {
|
||||
this.hasSearched = this.searchService.isSearchable(this.searchText);
|
||||
this.hasSearched = this.isSearchable;
|
||||
if (!this.hasLoadedAllCiphers && !this.hasSearched) {
|
||||
await this.loadCiphers();
|
||||
} else {
|
||||
@@ -381,9 +401,7 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
showSearching() {
|
||||
return (
|
||||
this.hasSearched || (!this.searchPending && this.searchService.isSearchable(this.searchText))
|
||||
);
|
||||
return this.hasSearched || (!this.searchPending && this.isSearchable);
|
||||
}
|
||||
|
||||
closeOnEsc(e: KeyboardEvent) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl
|
||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
|
||||
import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction";
|
||||
import { TotpService } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/vault/abstractions/totp.service";
|
||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||
import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
|
||||
import { LoginUriView } from "@bitwarden/common/vault/models/view/login-uri.view";
|
||||
@@ -74,7 +74,7 @@ export class ViewComponent extends BaseViewComponent {
|
||||
constructor(
|
||||
cipherService: CipherService,
|
||||
folderService: FolderService,
|
||||
totpService: TotpService,
|
||||
totpService: TotpServiceAbstraction,
|
||||
tokenService: TokenService,
|
||||
i18nService: I18nService,
|
||||
cryptoService: CryptoService,
|
||||
|
||||
@@ -414,7 +414,7 @@ export class Main {
|
||||
this.sendService,
|
||||
);
|
||||
|
||||
this.searchService = new SearchService(this.logService, this.i18nService);
|
||||
this.searchService = new SearchService(this.logService, this.i18nService, this.stateProvider);
|
||||
|
||||
this.broadcasterService = new BroadcasterService();
|
||||
|
||||
|
||||
@@ -609,7 +609,7 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||
// This must come last otherwise the logout will prematurely trigger
|
||||
// a process reload before all the state service user data can be cleaned up
|
||||
if (userBeingLoggedOut === preLogoutActiveUserId) {
|
||||
this.searchService.clearIndex();
|
||||
await this.searchService.clearIndex();
|
||||
this.authService.logOut(async () => {
|
||||
if (expired) {
|
||||
this.platformUtilsService.showToast(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Directive, ViewChild, ViewContainerRef } from "@angular/core";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
import { Directive, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
|
||||
import { BehaviorSubject, Subject, firstValueFrom, from, switchMap, takeUntil } from "rxjs";
|
||||
|
||||
import { SearchPipe } from "@bitwarden/angular/pipes/search.pipe";
|
||||
import { UserNamePipe } from "@bitwarden/angular/pipes/user-name.pipe";
|
||||
@@ -32,8 +32,10 @@ const MaxCheckedCount = 500;
|
||||
|
||||
@Directive()
|
||||
export abstract class BasePeopleComponent<
|
||||
UserType extends ProviderUserUserDetailsResponse | OrganizationUserView,
|
||||
> {
|
||||
UserType extends ProviderUserUserDetailsResponse | OrganizationUserView,
|
||||
>
|
||||
implements OnInit, OnDestroy
|
||||
{
|
||||
@ViewChild("confirmTemplate", { read: ViewContainerRef, static: true })
|
||||
confirmModalRef: ViewContainerRef;
|
||||
|
||||
@@ -88,7 +90,6 @@ export abstract class BasePeopleComponent<
|
||||
status: StatusType;
|
||||
users: UserType[] = [];
|
||||
pagedUsers: UserType[] = [];
|
||||
searchText: string;
|
||||
actionPromise: Promise<void>;
|
||||
|
||||
protected allUsers: UserType[] = [];
|
||||
@@ -97,7 +98,19 @@ export abstract class BasePeopleComponent<
|
||||
protected didScroll = false;
|
||||
protected pageSize = 100;
|
||||
|
||||
protected destroy$ = new Subject<void>();
|
||||
|
||||
private pagedUsersCount = 0;
|
||||
private _searchText$ = new BehaviorSubject<string>("");
|
||||
private isSearching: boolean = false;
|
||||
|
||||
get searchText() {
|
||||
return this._searchText$.value;
|
||||
}
|
||||
|
||||
set searchText(value: string) {
|
||||
this._searchText$.next(value);
|
||||
}
|
||||
|
||||
constructor(
|
||||
protected apiService: ApiService,
|
||||
@@ -122,6 +135,22 @@ export abstract class BasePeopleComponent<
|
||||
abstract reinviteUser(id: string): Promise<void>;
|
||||
abstract confirmUser(user: UserType, publicKey: Uint8Array): Promise<void>;
|
||||
|
||||
ngOnInit(): void {
|
||||
this._searchText$
|
||||
.pipe(
|
||||
switchMap((searchText) => from(this.searchService.isSearchable(searchText))),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe((isSearchable) => {
|
||||
this.isSearching = isSearchable;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
|
||||
async load() {
|
||||
const response = await this.getUsers();
|
||||
this.statusMap.clear();
|
||||
@@ -390,12 +419,8 @@ export abstract class BasePeopleComponent<
|
||||
}
|
||||
}
|
||||
|
||||
isSearching() {
|
||||
return this.searchService.isSearchable(this.searchText);
|
||||
}
|
||||
|
||||
isPaging() {
|
||||
const searching = this.isSearching();
|
||||
const searching = this.isSearching;
|
||||
if (searching && this.didScroll) {
|
||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
|
||||
@@ -91,15 +91,16 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||
private pagedGroupsCount = 0;
|
||||
private pagedGroups: GroupDetailsRow[];
|
||||
private searchedGroups: GroupDetailsRow[];
|
||||
private _searchText: string;
|
||||
private _searchText$ = new BehaviorSubject<string>("");
|
||||
private destroy$ = new Subject<void>();
|
||||
private refreshGroups$ = new BehaviorSubject<void>(null);
|
||||
private isSearching: boolean = false;
|
||||
|
||||
get searchText() {
|
||||
return this._searchText;
|
||||
return this._searchText$.value;
|
||||
}
|
||||
set searchText(value: string) {
|
||||
this._searchText = value;
|
||||
this._searchText$.next(value);
|
||||
// Manually update as we are not using the search pipe in the template
|
||||
this.updateSearchedGroups();
|
||||
}
|
||||
@@ -114,7 +115,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||
if (this.isPaging()) {
|
||||
return this.pagedGroups;
|
||||
}
|
||||
if (this.isSearching()) {
|
||||
if (this.isSearching) {
|
||||
return this.searchedGroups;
|
||||
}
|
||||
return this.groups;
|
||||
@@ -180,6 +181,15 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
this._searchText$
|
||||
.pipe(
|
||||
switchMap((searchText) => this.searchService.isSearchable(searchText)),
|
||||
takeUntil(this.destroy$),
|
||||
)
|
||||
.subscribe((isSearchable) => {
|
||||
this.isSearching = isSearchable;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
@@ -297,10 +307,6 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||
this.loadMore();
|
||||
}
|
||||
|
||||
isSearching() {
|
||||
return this.searchService.isSearchable(this.searchText);
|
||||
}
|
||||
|
||||
check(groupRow: GroupDetailsRow) {
|
||||
groupRow.checked = !groupRow.checked;
|
||||
}
|
||||
@@ -310,7 +316,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
isPaging() {
|
||||
const searching = this.isSearching();
|
||||
const searching = this.isSearching;
|
||||
if (searching && this.didScroll) {
|
||||
this.resetPaging();
|
||||
}
|
||||
@@ -340,7 +346,7 @@ export class GroupsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private updateSearchedGroups() {
|
||||
if (this.searchService.isSearchable(this.searchText)) {
|
||||
if (this.isSearching) {
|
||||
// Making use of the pipe in the component as we need know which groups where filtered
|
||||
this.searchedGroups = this.searchPipe.transform(
|
||||
this.groups,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Component, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
|
||||
import { Component, ViewChild, ViewContainerRef } from "@angular/core";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import {
|
||||
combineLatest,
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
map,
|
||||
Observable,
|
||||
shareReplay,
|
||||
Subject,
|
||||
switchMap,
|
||||
takeUntil,
|
||||
} from "rxjs";
|
||||
@@ -73,10 +72,7 @@ import { ResetPasswordComponent } from "./components/reset-password.component";
|
||||
selector: "app-org-people",
|
||||
templateUrl: "people.component.html",
|
||||
})
|
||||
export class PeopleComponent
|
||||
extends BasePeopleComponent<OrganizationUserView>
|
||||
implements OnInit, OnDestroy
|
||||
{
|
||||
export class PeopleComponent extends BasePeopleComponent<OrganizationUserView> {
|
||||
@ViewChild("groupsTemplate", { read: ViewContainerRef, static: true })
|
||||
groupsModalRef: ViewContainerRef;
|
||||
@ViewChild("confirmTemplate", { read: ViewContainerRef, static: true })
|
||||
@@ -99,7 +95,6 @@ export class PeopleComponent
|
||||
orgResetPasswordPolicyEnabled = false;
|
||||
|
||||
protected canUseSecretsManager$: Observable<boolean>;
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
constructor(
|
||||
apiService: ApiService,
|
||||
@@ -210,8 +205,7 @@ export class PeopleComponent
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
super.ngOnDestroy();
|
||||
}
|
||||
|
||||
async load() {
|
||||
|
||||
@@ -281,7 +281,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
|
||||
await this.stateEventRunnerService.handleEvent("logout", userId as UserId);
|
||||
|
||||
this.searchService.clearIndex();
|
||||
await this.searchService.clearIndex();
|
||||
this.authService.logOut(async () => {
|
||||
if (expired) {
|
||||
this.platformUtilsService.showToast(
|
||||
|
||||
@@ -272,7 +272,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
concatMap(async ([ciphers, filter, searchText]) => {
|
||||
const filterFunction = createFilterFunction(filter);
|
||||
|
||||
if (this.searchService.isSearchable(searchText)) {
|
||||
if (await this.searchService.isSearchable(searchText)) {
|
||||
return await this.searchService.searchCiphers(searchText, [filterFunction], ciphers);
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
|
||||
const collections$ = combineLatest([nestedCollections$, filter$, this.currentSearchText$]).pipe(
|
||||
filter(([collections, filter]) => collections != undefined && filter != undefined),
|
||||
map(([collections, filter, searchText]) => {
|
||||
concatMap(async ([collections, filter, searchText]) => {
|
||||
if (filter.collectionId === undefined || filter.collectionId === Unassigned) {
|
||||
return [];
|
||||
}
|
||||
@@ -303,7 +303,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
collectionsToReturn = selectedCollection?.children.map((c) => c.node) ?? [];
|
||||
}
|
||||
|
||||
if (this.searchService.isSearchable(searchText)) {
|
||||
if (await this.searchService.isSearchable(searchText)) {
|
||||
collectionsToReturn = this.searchPipe.transform(
|
||||
collectionsToReturn,
|
||||
searchText,
|
||||
|
||||
@@ -331,7 +331,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
this.searchService.indexCiphers(ciphers, organization.id);
|
||||
await this.searchService.indexCiphers(ciphers, organization.id);
|
||||
return ciphers;
|
||||
}),
|
||||
);
|
||||
@@ -350,7 +350,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
|
||||
const collections$ = combineLatest([nestedCollections$, filter$, this.currentSearchText$]).pipe(
|
||||
filter(([collections, filter]) => collections != undefined && filter != undefined),
|
||||
map(([collections, filter, searchText]) => {
|
||||
concatMap(async ([collections, filter, searchText]) => {
|
||||
if (
|
||||
filter.collectionId === Unassigned ||
|
||||
(filter.collectionId === undefined && filter.type !== undefined)
|
||||
@@ -369,7 +369,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
collectionsToReturn = selectedCollection?.children.map((c) => c.node) ?? [];
|
||||
}
|
||||
|
||||
if (this.searchService.isSearchable(searchText)) {
|
||||
if (await this.searchService.isSearchable(searchText)) {
|
||||
collectionsToReturn = this.searchPipe.transform(
|
||||
collectionsToReturn,
|
||||
searchText,
|
||||
@@ -436,7 +436,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
|
||||
const filterFunction = createFilterFunction(filter);
|
||||
|
||||
if (this.searchService.isSearchable(searchText)) {
|
||||
if (await this.searchService.isSearchable(searchText)) {
|
||||
return await this.searchService.searchCiphers(searchText, [filterFunction], ciphers);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user