mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 21:29:12 +00:00
Disable update button while indexing vault in plugin settings
This commit is contained in:
@@ -49,15 +49,26 @@ export class KhojSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.resultsCount = parseInt(value);
|
this.plugin.settings.resultsCount = parseInt(value);
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
}));
|
}));
|
||||||
new Setting(containerEl)
|
let indexVaultSetting = new Setting(containerEl);
|
||||||
|
indexVaultSetting
|
||||||
.setName('Index Vault')
|
.setName('Index Vault')
|
||||||
.setDesc('Manually force Khoj to re-index your Obsidian Vault')
|
.setDesc('Manually force Khoj to re-index your Obsidian Vault')
|
||||||
.addButton(button => button
|
.addButton(button => button
|
||||||
.setButtonText('Update')
|
.setButtonText('Update')
|
||||||
.setCta()
|
.setCta()
|
||||||
.onClick(async () => {
|
.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`)
|
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);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user