mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
* send list items container * update send list items container * finalize send list container * remove unecessary file * undo change to config * prefer use of takeUntilDestroyed * add send items service * and send list filters and service * undo changes to jest config * add specs for send list filters * Revert "Merge branch 'PM-9853' into PM-9852" This reverts commit9f65ded13f, reversing changes made to63f95600e8. * add send items service * Revert "Revert "Merge branch 'PM-9853' into PM-9852"" This reverts commit81e9860c25. * finish send search * fix formControlName * add specs * finalize send search * layout and copy fixes * cleanup * Remove unneeded empty file * Remove the erroneous addition of send-list-filters to vault-export tsconfig * update tests * hide send list filters for non-premium users * fix and add specss * Fix small typo * Re-add missing tests * Remove unused NgZone * Rename selector for send-search --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com> Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import { CommonModule } from "@angular/common";
|
|
import { Component } from "@angular/core";
|
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
import { FormsModule } from "@angular/forms";
|
|
import { Subject, Subscription, debounceTime, filter } from "rxjs";
|
|
|
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
|
import { SearchModule } from "@bitwarden/components";
|
|
|
|
import { SendItemsService } from "../services/send-items.service";
|
|
|
|
const SearchTextDebounceInterval = 200;
|
|
|
|
@Component({
|
|
imports: [CommonModule, SearchModule, JslibModule, FormsModule],
|
|
standalone: true,
|
|
selector: "tools-send-search",
|
|
templateUrl: "send-search.component.html",
|
|
})
|
|
export class SendSearchComponent {
|
|
searchText: string;
|
|
|
|
private searchText$ = new Subject<string>();
|
|
|
|
constructor(private sendListItemService: SendItemsService) {
|
|
this.subscribeToLatestSearchText();
|
|
this.subscribeToApplyFilter();
|
|
}
|
|
|
|
onSearchTextChanged() {
|
|
this.searchText$.next(this.searchText);
|
|
}
|
|
|
|
subscribeToLatestSearchText(): Subscription {
|
|
return this.sendListItemService.latestSearchText$
|
|
.pipe(
|
|
takeUntilDestroyed(),
|
|
filter((data) => !!data),
|
|
)
|
|
.subscribe((text) => {
|
|
this.searchText = text;
|
|
});
|
|
}
|
|
|
|
subscribeToApplyFilter(): Subscription {
|
|
return this.searchText$
|
|
.pipe(debounceTime(SearchTextDebounceInterval), takeUntilDestroyed())
|
|
.subscribe((data) => {
|
|
this.sendListItemService.applyFilter(data);
|
|
});
|
|
}
|
|
}
|