From 5996d47d7c16e45fe92fd29ec7c00cad1e049feb Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Wed, 11 Jan 2023 11:08:28 -0300 Subject: [PATCH] Trigger input event to Get, Render Reranked results from Khoj backend Previous mechanism of manually triggering getSuggestions, renderSuggestions flow was corrupting traversing and opening reranked search results in KhojModal Emulate event that would anyway trigger the get & render of results in modal. This lets obsidian core handle the flow without digging too deep into obsidian cores handling of the flow. Lowers the chance of breakage --- src/interface/obsidian/src/modal.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/interface/obsidian/src/modal.ts b/src/interface/obsidian/src/modal.ts index af4455a6..11354e32 100644 --- a/src/interface/obsidian/src/modal.ts +++ b/src/interface/obsidian/src/modal.ts @@ -9,22 +9,19 @@ export interface SearchResult { export class KhojModal extends SuggestModal { setting: KhojSetting; - rerank: boolean; + rerank: boolean = false; constructor(app: App, setting: KhojSetting) { super(app); this.setting = setting; - this.rerank = false; // Register Modal Keybindings to Rerank Results this.scope.register(['Mod'], 'Enter', async () => { + // Re-rank when explicitly triggered by user this.rerank = true - let results = await this.getSuggestions(this.inputEl.value); - - this.resultContainerEl.empty(); - results.forEach((result) => { - this.renderSuggestion(result, this.resultContainerEl); - }); + // Trigger input event to get and render (reranked) results from khoj backend + this.inputEl.dispatchEvent(new Event('input')); + // Rerank disabled by default to satisfy latency requirements for incremental search this.rerank = false });