#134 - Async loading of minisearch cache

Using a custom build of minisearch
This commit is contained in:
Simon Cambier
2024-05-23 21:38:46 +02:00
parent dcfb77f551
commit 5f5417f0ff
5 changed files with 2662 additions and 3184 deletions

View File

@@ -59,6 +59,7 @@ export class Omnisearch {
}
},
}
private minisearch: MiniSearch
/** Map<path, mtime> */
private indexedDocuments: Map<string, number> = new Map()
@@ -75,8 +76,7 @@ export class Omnisearch {
async loadCache(): Promise<boolean> {
const cache = await cacheManager.getMinisearchCache()
if (cache) {
// console.log('Omnisearch - Cache', cache)
this.minisearch = MiniSearch.loadJS(cache.data, Omnisearch.options)
this.minisearch = await MiniSearch.loadJSAsync(cache.data, Omnisearch.options)
this.indexedDocuments = new Map(cache.paths.map(o => [o.path, o.mtime]))
return true
}