Handles normalization on search fields for browser and desktop

This commit is contained in:
gbubemismith 2022-05-23 12:13:54 +01:00
parent 2a2e9a0d7f
commit 4d4a4259c2
3 changed files with 6 additions and 7 deletions

View File

@ -193,11 +193,10 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
clearTimeout(this.searchTimeout);
}
const filterDeleted = (c: CipherView) => !c.isDeleted;
const normalizedSearchText = this.searchText?.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
if (timeout == null) {
this.hasSearched = this.searchService.isSearchable(normalizedSearchText);
this.hasSearched = this.searchService.isSearchable(this.searchText);
this.ciphers = await this.searchService.searchCiphers(
normalizedSearchText,
this.searchText,
filterDeleted,
this.allCiphers
);
@ -208,12 +207,12 @@ export class VaultFilterComponent implements OnInit, OnDestroy {
}
this.searchPending = true;
this.searchTimeout = setTimeout(async () => {
this.hasSearched = this.searchService.isSearchable(normalizedSearchText);
this.hasSearched = this.searchService.isSearchable(this.searchText);
if (!this.hasLoadedAllCiphers && !this.hasSearched) {
await this.loadCiphers();
} else {
this.ciphers = await this.searchService.searchCiphers(
normalizedSearchText,
this.searchText,
filterDeleted,
this.allCiphers
);

View File

@ -29,7 +29,7 @@ export class SearchBarService {
}
setSearchText(value: string) {
this.searchText.next(value);
this.searchText.next(value?.normalize("NFD").replace(/[\u0300-\u036f]/g, ""));
}
private updateState() {

View File

@ -17,7 +17,7 @@ export class SearchComponent {
});
this.searchText.valueChanges.subscribe((value) => {
this.searchBarService.setSearchText(value.normalize("NFD").replace(/[\u0300-\u036f]/g, ""));
this.searchBarService.setSearchText(value);
});
}
}