From 833ab52986566bf449537fb392426bcc0e0b7744 Mon Sep 17 00:00:00 2001 From: Henri Jamet <42291955+hjamet@users.noreply.github.com> Date: Sun, 29 Dec 2024 12:51:52 +0100 Subject: [PATCH] Add manual sync command to Khoj plugin - Introduced a new command 'Sync new changes' to allow users to manually synchronize new modifications. - The command updates the content index without regenerating it, ensuring only new changes are synced. - User-triggered notifications are displayed upon successful sync. --- src/interface/obsidian/src/main.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/interface/obsidian/src/main.ts b/src/interface/obsidian/src/main.ts index bf7cad54..f5f80cfc 100644 --- a/src/interface/obsidian/src/main.ts +++ b/src/interface/obsidian/src/main.ts @@ -34,6 +34,21 @@ export default class Khoj extends Plugin { callback: () => { this.activateView(KhojView.CHAT); } }); + // Add sync command to manually sync new changes + this.addCommand({ + id: 'sync', + name: 'Sync new changes', + callback: async () => { + this.settings.lastSync = await updateContentIndex( + this.app.vault, + this.settings, + this.settings.lastSync, + false, // regenerate = false pour ne synchroniser que les nouvelles modifications + true // userTriggered = true pour afficher une notification + ); + } + }); + this.registerView(KhojView.CHAT, (leaf) => new KhojChatView(leaf, this.settings)); // Create an icon in the left ribbon.