mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
[PS-713] Fix locale search bug (#3014)
* [PS-713] Fix locale search bug * [PS-713] Add new locales to start at 1 char search * [PS-713] Switch to ReplaySubject and other edits from PR comments * PS-713: Add destroy to other sub and make locale inline a const * PS-713: Use firstValueFrom instead of takeUntil * PS-713: get this.locale asynchronously Co-authored-by: Colton Hurst <churst@bitwarden.com>
This commit is contained in:
@@ -14,16 +14,23 @@ export class SearchService implements SearchServiceAbstraction {
|
||||
indexedEntityId?: string = null;
|
||||
private indexing = false;
|
||||
private index: lunr.Index = null;
|
||||
private searchableMinLength = 2;
|
||||
private readonly immediateSearchLocales: string[] = ["zh-CN", "zh-TW", "ja", "ko", "vi"];
|
||||
private readonly defaultSearchableMinLength: number = 2;
|
||||
private searchableMinLength: number = this.defaultSearchableMinLength;
|
||||
|
||||
constructor(
|
||||
private cipherService: CipherService,
|
||||
private logService: LogService,
|
||||
private i18nService: I18nService
|
||||
) {
|
||||
if (["zh-CN", "zh-TW"].indexOf(i18nService.locale) !== -1) {
|
||||
this.searchableMinLength = 1;
|
||||
}
|
||||
this.i18nService.locale$.subscribe((locale) => {
|
||||
if (this.immediateSearchLocales.indexOf(locale) !== -1) {
|
||||
this.searchableMinLength = 1;
|
||||
} else {
|
||||
this.searchableMinLength = this.defaultSearchableMinLength;
|
||||
}
|
||||
});
|
||||
|
||||
//register lunr pipeline function
|
||||
lunr.Pipeline.registerFunction(this.normalizeAccentsPipelineFunction, "normalizeAccents");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user