1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 07:43:35 +00:00

[PM-12045] search service activeuserstate (#13035)

* removing activeuserstate from search service
This commit is contained in:
Jason Ng
2025-03-06 12:26:24 -05:00
committed by GitHub
parent 9761588a2a
commit f65daf7284
19 changed files with 159 additions and 637 deletions

View File

@@ -3,8 +3,12 @@ import { mock } from "jest-mock-extended";
import { BehaviorSubject, first, Subject } from "rxjs";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
import { UserId } from "@bitwarden/common/types/guid";
import { mockAccountServiceWith } from "../../../../../common/spec";
import { SendItemsService } from "./send-items.service";
import { SendListFiltersService } from "./send-list-filters.service";
@@ -30,6 +34,7 @@ describe("SendItemsService", () => {
{ provide: SendService, useValue: sendServiceMock },
{ provide: SendListFiltersService, useValue: sendListFiltersServiceMock },
{ provide: SearchService, useValue: searchServiceMock },
{ provide: AccountService, useValue: mockAccountServiceWith("UserId" as UserId) },
SendItemsService,
],
});

View File

@@ -15,6 +15,8 @@ import {
} from "rxjs";
import { SearchService } from "@bitwarden/common/abstractions/search.service";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { getUserId } from "@bitwarden/common/auth/services/account.service";
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
@@ -71,9 +73,13 @@ export class SendItemsService {
/**
* Observable that indicates whether a filter is currently applied to the sends.
*/
hasFilterApplied$ = combineLatest([this._searchText$, this.sendListFiltersService.filters$]).pipe(
switchMap(([searchText, filters]) => {
return from(this.searchService.isSearchable(searchText)).pipe(
hasFilterApplied$ = combineLatest([
this._searchText$,
this.sendListFiltersService.filters$,
getUserId(this.accountService.activeAccount$),
]).pipe(
switchMap(([searchText, filters, activeAcctId]) => {
return from(this.searchService.isSearchable(activeAcctId, searchText)).pipe(
map(
(isSearchable) =>
isSearchable || Object.values(filters).some((filter) => filter !== null),
@@ -98,6 +104,7 @@ export class SendItemsService {
private sendService: SendService,
private sendListFiltersService: SendListFiltersService,
private searchService: SearchService,
private accountService: AccountService,
) {}
applyFilter(newSearchText: string) {