#57 - only update the index when Omnisearch is loaded

This commit is contained in:
Simon Cambier
2022-06-17 18:44:44 +02:00
parent f5d1cbe932
commit 21f936e4ee
4 changed files with 17 additions and 52 deletions

View File

@@ -388,9 +388,13 @@ export function addNoteToReindex(note: TAbstractFile): void {
notesToReindex.add(note)
}
export async function reindexNotes(): Promise<void> {
if (settings.showIndexingNotices && notesToReindex.size > 0) {
new Notice(`Omnisearch - Reindexing ${notesToReindex.size} notes`, 2000)
}
for (const note of notesToReindex) {
removeFromIndex(note.path)
await addToIndex(note)
await wait(0)
}
notesToReindex.clear()
@@ -401,7 +405,7 @@ async function saveIndexToFile(): Promise<void> {
if (settings.storeIndexInFile && minisearchInstance && isIndexChanged) {
const json = JSON.stringify(minisearchInstance)
await app.vault.adapter.write(searchIndexFilePath, json)
console.log('MiniSearch index saved to the file')
console.log('Omnisearch - Index saved on disk')
await saveNotesCacheToFile()
isIndexChanged = false