mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-30 10:53:02 +01:00
Only call search API when pause in typing search query on web, desktop apps
Wait for 300ms since stop typing before calling search API. This smooths out UI jitter when rendering search results, especially now that we're reranking for every search query on GPU enabled devices Emacs already has 300ms debounce time. More convoluted to add debounce time to Obsidian search modal, so not updating that yet
This commit is contained in:
parent
1105d8814f
commit
44c8d09342
2 changed files with 20 additions and 18 deletions
|
@ -192,16 +192,17 @@
|
|||
});
|
||||
}
|
||||
|
||||
let debounceTimeout;
|
||||
function incrementalSearch(event) {
|
||||
// Run incremental search only after waitTime passed since the last key press
|
||||
let waitTime = 300;
|
||||
clearTimeout(debounceTimeout);
|
||||
debounceTimeout = setTimeout(() => {
|
||||
type = 'all';
|
||||
// Search with reranking on 'Enter'
|
||||
if (event.key === 'Enter') {
|
||||
search(rerank=true);
|
||||
}
|
||||
// Limit incremental search to text types
|
||||
else if (type !== "image") {
|
||||
search(rerank=false);
|
||||
}
|
||||
let should_rerank = event.key === 'Enter';
|
||||
search(rerank=should_rerank);
|
||||
}, waitTime);
|
||||
}
|
||||
|
||||
async function populate_type_dropdown() {
|
||||
|
|
|
@ -193,16 +193,17 @@
|
|||
});
|
||||
}
|
||||
|
||||
let debounceTimeout;
|
||||
function incrementalSearch(event) {
|
||||
// Run incremental search only after waitTime passed since the last key press
|
||||
let waitTime = 300;
|
||||
clearTimeout(debounceTimeout);
|
||||
debounceTimeout = setTimeout(() => {
|
||||
type = document.getElementById("type").value;
|
||||
// Search with reranking on 'Enter'
|
||||
if (event.key === 'Enter') {
|
||||
search(rerank=true);
|
||||
}
|
||||
// Limit incremental search to text types
|
||||
else if (type !== "image") {
|
||||
search(rerank=false);
|
||||
}
|
||||
let should_rerank = event.key === 'Enter';
|
||||
search(rerank=should_rerank);
|
||||
}, waitTime);
|
||||
}
|
||||
|
||||
function populate_type_dropdown() {
|
||||
|
|
Loading…
Reference in a new issue