1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-23 11:43:46 +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:
SmithThe4th
2024-04-10 14:02:46 +01:00
committed by GitHub
parent 560033cb88
commit 2bce6c538c
30 changed files with 393 additions and 182 deletions

View File

@@ -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,