mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
Allow external awaits of indexing (#359)
* Allow external awaits of indexing We were getting stuck in an infinite load loop where we were basing logic on a dirty state of search service. This await enables us to wait until an index is complete, then update it rather than being kicked out of indexing early because it is in progress. * Stop infinite loop by specifying ciphers to index
This commit is contained in:
parent
b6f102938f
commit
5be76c1a63
@ -297,7 +297,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
const userId = await this.userService.getUserId();
|
||||
if ((this.searchService().indexedEntityId ?? userId) !== userId)
|
||||
{
|
||||
await this.searchService().indexCiphers();
|
||||
await this.searchService().indexCiphers(userId, this.decryptedCipherCache);
|
||||
}
|
||||
return this.decryptedCipherCache;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ export class SearchService implements SearchServiceAbstraction {
|
||||
}
|
||||
|
||||
clearIndex(): void {
|
||||
this.indexedEntityId = null;
|
||||
this.index = null;
|
||||
}
|
||||
|
||||
@ -42,6 +43,7 @@ export class SearchService implements SearchServiceAbstraction {
|
||||
|
||||
this.logService.time('search indexing');
|
||||
this.indexing = true;
|
||||
this.indexedEntityId = indexedEntityId;
|
||||
this.index = null;
|
||||
const builder = new lunr.Builder();
|
||||
builder.ref('id');
|
||||
@ -70,7 +72,7 @@ export class SearchService implements SearchServiceAbstraction {
|
||||
ciphers = ciphers || await this.cipherService.getAllDecrypted();
|
||||
ciphers.forEach(c => builder.add(c));
|
||||
this.index = builder.build();
|
||||
this.indexedEntityId = indexedEntityId;
|
||||
|
||||
this.indexing = false;
|
||||
|
||||
this.logService.timeEnd('search indexing');
|
||||
|
Loading…
Reference in New Issue
Block a user