Send search (#258)

* fixed text searching sends

* fixed text searching sends

* cleanup

* cleanup
This commit is contained in:
Addison Beck 2021-02-03 15:36:15 -05:00 committed by GitHub
parent 11249e3444
commit a16d8f7de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import { SendView } from '../../../models/view/sendView';
import { EnvironmentService } from '../../../abstractions/environment.service'; import { EnvironmentService } from '../../../abstractions/environment.service';
import { I18nService } from '../../../abstractions/i18n.service'; import { I18nService } from '../../../abstractions/i18n.service';
import { PlatformUtilsService } from '../../../abstractions/platformUtils.service'; import { PlatformUtilsService } from '../../../abstractions/platformUtils.service';
import { SearchService } from '../../../abstractions/search.service';
import { SendService } from '../../../abstractions/send.service'; import { SendService } from '../../../abstractions/send.service';
import { BroadcasterService } from '../../../angular/services/broadcaster.service'; import { BroadcasterService } from '../../../angular/services/broadcaster.service';
@ -41,7 +42,8 @@ export class SendComponent implements OnInit {
constructor(protected sendService: SendService, protected i18nService: I18nService, constructor(protected sendService: SendService, protected i18nService: I18nService,
protected platformUtilsService: PlatformUtilsService, protected environmentService: EnvironmentService, protected platformUtilsService: PlatformUtilsService, protected environmentService: EnvironmentService,
protected broadcasterService: BroadcasterService, protected ngZone: NgZone) { } protected broadcasterService: BroadcasterService, protected ngZone: NgZone,
protected searchService: SearchService) { }
async ngOnInit() { async ngOnInit() {
this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => { this.broadcasterService.subscribe(BroadcasterSubscriptionId, (message: any) => {
@ -99,11 +101,13 @@ export class SendComponent implements OnInit {
} }
if (timeout == null) { if (timeout == null) {
this.filteredSends = this.sends.filter((s) => this.filter == null || this.filter(s)); this.filteredSends = this.sends.filter((s) => this.filter == null || this.filter(s));
this.applyTextSearch();
return; return;
} }
this.searchPending = true; this.searchPending = true;
this.searchTimeout = setTimeout(async () => { this.searchTimeout = setTimeout(async () => {
this.filteredSends = this.sends.filter((s) => this.filter == null || this.filter(s)); this.filteredSends = this.sends.filter((s) => this.filter == null || this.filter(s));
this.applyTextSearch();
this.searchPending = false; this.searchPending = false;
}, timeout); }, timeout);
} }
@ -192,4 +196,10 @@ export class SendComponent implements OnInit {
this.selectedAll = false; this.selectedAll = false;
this.selectedType = null; this.selectedType = null;
} }
private applyTextSearch() {
if (this.searchText != null) {
this.filteredSends = this.searchService.searchSends(this.filteredSends, this.searchText);
}
}
} }