Add button in Obsidian plugin settings to force re-indexing your vault

This commit is contained in:
Debanjum Singh Solanky 2023-01-10 19:49:12 -03:00
parent f046a95f3d
commit 7991ab7a86

View file

@ -1,4 +1,4 @@
import { App, PluginSettingTab, Setting } from 'obsidian';
import { App, PluginSettingTab, request, Setting } from 'obsidian';
import Khoj from 'src/main';
import { getVaultAbsolutePath } from 'src/utils';
@ -35,7 +35,7 @@ export class KhojSettingTab extends PluginSettingTab {
// Add khoj settings configurable from the plugin settings tab
new Setting(containerEl)
.setName('Vault Paths')
.setName('Vault Path')
.setDesc('The Obsidian Vault to search with Khoj')
.addText(text => text
.setValue(`${this.plugin.settings.obsidianVaultPath}`)
@ -53,7 +53,7 @@ export class KhojSettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Number of Results')
.setName('Results Count')
.setDesc('The number of search results to show')
.addText(text => text
.setPlaceholder('6')
@ -62,5 +62,14 @@ export class KhojSettingTab extends PluginSettingTab {
this.plugin.settings.resultsCount = parseInt(value);
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Index Vault')
.setDesc('Manually force Khoj to re-index your Obsidian Vault')
.addButton(button => button
.setButtonText('Update')
.onClick(async () => {
await request(`${this.plugin.settings.khojUrl}/api/update?t=markdown&force=true`);
}
));
}
}