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:
@@ -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,
|
||||
],
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user