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
This commit is contained in:
Debanjum Singh Solanky
2023-01-11 11:08:28 -03:00
parent 1c813a6884
commit 5996d47d7c

View File

@@ -9,22 +9,19 @@ export interface SearchResult {
export class KhojModal extends SuggestModal<SearchResult> {
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
});