mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-04 05:39:06 +00:00
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:
@@ -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
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user