refactor search method in fido2 component to only show ciphers with matching uri when search text is empty (#6628)
This commit is contained in:
parent
fbe960e760
commit
742e6e3b95
|
@ -20,7 +20,7 @@
|
||||||
placeholder="{{ 'searchVault' | i18n }}"
|
placeholder="{{ 'searchVault' | i18n }}"
|
||||||
id="search"
|
id="search"
|
||||||
[(ngModel)]="searchText"
|
[(ngModel)]="searchText"
|
||||||
(input)="search(200)"
|
(input)="search()"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
appAutofocus
|
appAutofocus
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -319,46 +319,23 @@ export class Fido2Component implements OnInit, OnDestroy {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadLoginCiphers() {
|
protected async search() {
|
||||||
this.ciphers = (await this.cipherService.getAllDecrypted()).filter(
|
this.hasSearched = this.searchService.isSearchable(this.searchText);
|
||||||
(cipher) => cipher.type === CipherType.Login && !cipher.isDeleted
|
this.searchPending = true;
|
||||||
);
|
if (this.hasSearched) {
|
||||||
if (!this.hasLoadedAllCiphers) {
|
|
||||||
this.hasLoadedAllCiphers = !this.searchService.isSearchable(this.searchText);
|
|
||||||
}
|
|
||||||
await this.search(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
async search(timeout: number = null) {
|
|
||||||
this.searchPending = false;
|
|
||||||
if (this.searchTimeout != null) {
|
|
||||||
clearTimeout(this.searchTimeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timeout == null) {
|
|
||||||
this.hasSearched = this.searchService.isSearchable(this.searchText);
|
|
||||||
this.displayedCiphers = await this.searchService.searchCiphers(
|
this.displayedCiphers = await this.searchService.searchCiphers(
|
||||||
this.searchText,
|
this.searchText,
|
||||||
null,
|
null,
|
||||||
this.ciphers
|
this.ciphers
|
||||||
);
|
);
|
||||||
return;
|
} else {
|
||||||
|
const equivalentDomains = this.settingsService.getEquivalentDomains(this.url);
|
||||||
|
this.displayedCiphers = this.ciphers.filter((cipher) =>
|
||||||
|
cipher.login.matchesUri(this.url, equivalentDomains)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
this.searchPending = true;
|
this.searchPending = false;
|
||||||
this.searchTimeout = setTimeout(async () => {
|
this.selectedPasskey(this.displayedCiphers[0]);
|
||||||
this.hasSearched = this.searchService.isSearchable(this.searchText);
|
|
||||||
if (!this.hasLoadedAllCiphers && !this.hasSearched) {
|
|
||||||
await this.loadLoginCiphers();
|
|
||||||
} else {
|
|
||||||
this.displayedCiphers = await this.searchService.searchCiphers(
|
|
||||||
this.searchText,
|
|
||||||
null,
|
|
||||||
this.ciphers
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.searchPending = false;
|
|
||||||
this.selectedPasskey(this.displayedCiphers[0]);
|
|
||||||
}, timeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abort(fallback: boolean) {
|
abort(fallback: boolean) {
|
||||||
|
|
Loading…
Reference in New Issue