mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Disable update button while indexing vault in plugin settings
This commit is contained in:
parent
513c86c6a1
commit
4e1abd1b72
1 changed files with 13 additions and 2 deletions
|
@ -49,15 +49,26 @@ export class KhojSettingTab extends PluginSettingTab {
|
|||
this.plugin.settings.resultsCount = parseInt(value);
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
new Setting(containerEl)
|
||||
let indexVaultSetting = new Setting(containerEl);
|
||||
indexVaultSetting
|
||||
.setName('Index Vault')
|
||||
.setDesc('Manually force Khoj to re-index your Obsidian Vault')
|
||||
.addButton(button => button
|
||||
.setButtonText('Update')
|
||||
.setCta()
|
||||
.onClick(async () => {
|
||||
// Disable button while updating index
|
||||
button.setButtonText('Updating...');
|
||||
button.removeCta()
|
||||
indexVaultSetting = indexVaultSetting.setDisabled(true);
|
||||
|
||||
await request(`${this.plugin.settings.khojUrl}/api/update?t=markdown&force=true`)
|
||||
.then(() => new Notice('✅ Updated Khoj index.'))
|
||||
.then(() => new Notice('✅ Updated Khoj index.'));
|
||||
|
||||
// Re-enable button once index is updated
|
||||
button.setButtonText('Update');
|
||||
button.setCta()
|
||||
indexVaultSetting = indexVaultSetting.setDisabled(false);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue