Add missing async/await (#269)

This commit is contained in:
YuNing Chen
2023-08-03 18:53:59 +08:00
committed by GitHub
parent 0263018f65
commit a077b427eb
3 changed files with 6 additions and 6 deletions

View File

@@ -103,7 +103,7 @@ export default class OmnisearchPlugin extends Plugin {
if (isFileIndexable(file.path)) { if (isFileIndexable(file.path)) {
logDebug('Renaming file', file.path) logDebug('Renaming file', file.path)
cacheManager.removeFromLiveCache(oldPath) cacheManager.removeFromLiveCache(oldPath)
cacheManager.addToLiveCache(file.path) await cacheManager.addToLiveCache(file.path)
searchEngine.removeFromPaths([oldPath]) searchEngine.removeFromPaths([oldPath])
await searchEngine.addFromPaths([file.path]) await searchEngine.addFromPaths([file.path])
} }
@@ -206,14 +206,14 @@ export default class OmnisearchPlugin extends Plugin {
// Disable settings.useCache while writing the cache, in case it freezes // Disable settings.useCache while writing the cache, in case it freezes
settings.useCache = false settings.useCache = false
saveSettings(this) await saveSettings(this)
// Write the cache // Write the cache
await searchEngine.writeToCache() await searchEngine.writeToCache()
// Re-enable settings.caching // Re-enable settings.caching
settings.useCache = true settings.useCache = true
saveSettings(this) await saveSettings(this)
} }
console.timeEnd('Omnisearch - Indexing total time') console.timeEnd('Omnisearch - Indexing total time')

View File

@@ -43,7 +43,7 @@ export async function refreshIndex(): Promise<void> {
const paths = [...notesToReindex].map(n => n.path) const paths = [...notesToReindex].map(n => n.path)
if (paths.length) { if (paths.length) {
searchEngine.removeFromPaths(paths) searchEngine.removeFromPaths(paths)
searchEngine.addFromPaths(paths) await searchEngine.addFromPaths(paths)
notesToReindex.clear() notesToReindex.clear()
// console.log(`Omnisearch - Reindexed ${paths.length} file(s)`) // console.log(`Omnisearch - Reindexed ${paths.length} file(s)`)
} }

View File

@@ -507,9 +507,9 @@ export class SettingsTab extends PluginSettingTab {
cb.setLimits(1, 5, 0.1) cb.setLimits(1, 5, 0.1)
.setValue(settings[key]) .setValue(settings[key])
.setDynamicTooltip() .setDynamicTooltip()
.onChange(v => { .onChange(async (v) => {
settings[key] = v settings[key] = v
saveSettings(this.plugin) await saveSettings(this.plugin)
}) })
} }
} }