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.
This commit is contained in:
Henri Jamet
2024-12-29 12:51:52 +01:00
parent 1a43ca75f3
commit 833ab52986

View File

@@ -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.