1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

search pending and is searchable

This commit is contained in:
Kyle Spearrin
2018-08-13 11:52:55 -04:00
parent b724448081
commit d917651d9f
3 changed files with 18 additions and 3 deletions

View File

@@ -22,6 +22,7 @@ export class CiphersComponent {
protected allCiphers: CipherView[] = [];
protected filter: (cipher: CipherView) => boolean = null;
protected searchPending = false;
private searchTimeout: any = null;
@@ -40,15 +41,22 @@ export class CiphersComponent {
async applyFilter(filter: (cipher: CipherView) => boolean = null) {
this.filter = filter;
await this.search(0);
await this.search(null);
}
search(timeout: number = 0) {
async search(timeout: number = null) {
this.searchPending = false;
if (this.searchTimeout != null) {
clearTimeout(this.searchTimeout);
}
if (timeout == null) {
this.ciphers = await this.searchService.searchCiphers(this.searchText, this.filter);
return;
}
this.searchPending = true;
this.searchTimeout = setTimeout(async () => {
this.ciphers = await this.searchService.searchCiphers(this.searchText, this.filter);
this.searchPending = false;
}, timeout);
}