#21 Index files after obsidian is correctly loaded
This commit is contained in:
52
src/main.ts
52
src/main.ts
@@ -34,32 +34,34 @@ export default class OmnisearchPlugin extends Plugin {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
// Listeners to keep the search index up-to-date
|
app.workspace.onLayoutReady(async () => {
|
||||||
this.registerEvent(
|
// Listeners to keep the search index up-to-date
|
||||||
this.app.vault.on('create', file => {
|
this.registerEvent(
|
||||||
addToIndex(file)
|
this.app.vault.on('create', file => {
|
||||||
}),
|
addToIndex(file)
|
||||||
)
|
}),
|
||||||
this.registerEvent(
|
)
|
||||||
this.app.vault.on('delete', file => {
|
this.registerEvent(
|
||||||
removeFromIndex(file)
|
this.app.vault.on('delete', file => {
|
||||||
}),
|
removeFromIndex(file)
|
||||||
)
|
}),
|
||||||
this.registerEvent(
|
)
|
||||||
this.app.vault.on('modify', async file => {
|
this.registerEvent(
|
||||||
removeFromIndex(file)
|
this.app.vault.on('modify', async file => {
|
||||||
await addToIndex(file)
|
removeFromIndex(file)
|
||||||
}),
|
|
||||||
)
|
|
||||||
this.registerEvent(
|
|
||||||
this.app.vault.on('rename', async (file, oldPath) => {
|
|
||||||
if (file instanceof TFile && file.path.endsWith('.md')) {
|
|
||||||
removeFromIndexByPath(oldPath)
|
|
||||||
await addToIndex(file)
|
await addToIndex(file)
|
||||||
}
|
}),
|
||||||
}),
|
)
|
||||||
)
|
this.registerEvent(
|
||||||
|
this.app.vault.on('rename', async (file, oldPath) => {
|
||||||
|
if (file instanceof TFile && file.path.endsWith('.md')) {
|
||||||
|
removeFromIndexByPath(oldPath)
|
||||||
|
await addToIndex(file)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
initGlobalSearchIndex()
|
await initGlobalSearchIndex()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user