mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 13:25:11 +00:00
Indicate indexing active on Update button in Obsidian plugin settings
Use moon rotating through phases to indicate notes indexing in progress Resolves #129
This commit is contained in:
@@ -59,14 +59,37 @@ export class KhojSettingTab extends PluginSettingTab {
|
|||||||
.setCta()
|
.setCta()
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
// Disable button while updating index
|
// Disable button while updating index
|
||||||
button.setButtonText('Updating...');
|
button.setButtonText('Updating 🌑');
|
||||||
button.removeCta();
|
button.removeCta();
|
||||||
indexVaultSetting = indexVaultSetting.setDisabled(true);
|
indexVaultSetting = indexVaultSetting.setDisabled(true);
|
||||||
|
|
||||||
|
// Show indicator for indexing in progress
|
||||||
|
const progress_indicator = window.setInterval(() => {
|
||||||
|
if (button.buttonEl.innerText === 'Updating 🌑') {
|
||||||
|
button.setButtonText('Updating 🌘');
|
||||||
|
} else if (button.buttonEl.innerText === 'Updating 🌘') {
|
||||||
|
button.setButtonText('Updating 🌗');
|
||||||
|
} else if (button.buttonEl.innerText === 'Updating 🌗') {
|
||||||
|
button.setButtonText('Updating 🌖');
|
||||||
|
} else if (button.buttonEl.innerText === 'Updating 🌖') {
|
||||||
|
button.setButtonText('Updating 🌕');
|
||||||
|
} else if (button.buttonEl.innerText === 'Updating 🌕') {
|
||||||
|
button.setButtonText('Updating 🌔');
|
||||||
|
} else if (button.buttonEl.innerText === 'Updating 🌔') {
|
||||||
|
button.setButtonText('Updating 🌓');
|
||||||
|
} else if (button.buttonEl.innerText === 'Updating 🌓') {
|
||||||
|
button.setButtonText('Updating 🌒');
|
||||||
|
} else if (button.buttonEl.innerText === 'Updating 🌒') {
|
||||||
|
button.setButtonText('Updating 🌑');
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
this.plugin.registerInterval(progress_indicator);
|
||||||
|
|
||||||
await request(`${this.plugin.settings.khojUrl}/api/update?t=markdown&force=true`);
|
await request(`${this.plugin.settings.khojUrl}/api/update?t=markdown&force=true`);
|
||||||
new Notice('✅ Updated Khoj index.');
|
new Notice('✅ Updated Khoj index.');
|
||||||
|
|
||||||
// Re-enable button once index is updated
|
// Reset button once index is updated
|
||||||
|
window.clearInterval(progress_indicator);
|
||||||
button.setButtonText('Update');
|
button.setButtonText('Update');
|
||||||
button.setCta();
|
button.setCta();
|
||||||
indexVaultSetting = indexVaultSetting.setDisabled(false);
|
indexVaultSetting = indexVaultSetting.setDisabled(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user