1
0
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:
Matt Gibson 2021-04-23 13:55:57 -05:00 committed by GitHub
parent b6f102938f
commit 5be76c1a63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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;
}

View File

@ -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');