mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-06 13:22:12 +00: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:
@@ -192,16 +192,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let debounceTimeout;
|
||||||
function incrementalSearch(event) {
|
function incrementalSearch(event) {
|
||||||
|
// Run incremental search only after waitTime passed since the last key press
|
||||||
|
let waitTime = 300;
|
||||||
|
clearTimeout(debounceTimeout);
|
||||||
|
debounceTimeout = setTimeout(() => {
|
||||||
type = 'all';
|
type = 'all';
|
||||||
// Search with reranking on 'Enter'
|
// Search with reranking on 'Enter'
|
||||||
if (event.key === 'Enter') {
|
let should_rerank = event.key === 'Enter';
|
||||||
search(rerank=true);
|
search(rerank=should_rerank);
|
||||||
}
|
}, waitTime);
|
||||||
// Limit incremental search to text types
|
|
||||||
else if (type !== "image") {
|
|
||||||
search(rerank=false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function populate_type_dropdown() {
|
async function populate_type_dropdown() {
|
||||||
|
|||||||
@@ -193,16 +193,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let debounceTimeout;
|
||||||
function incrementalSearch(event) {
|
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;
|
type = document.getElementById("type").value;
|
||||||
// Search with reranking on 'Enter'
|
// Search with reranking on 'Enter'
|
||||||
if (event.key === 'Enter') {
|
let should_rerank = event.key === 'Enter';
|
||||||
search(rerank=true);
|
search(rerank=should_rerank);
|
||||||
}
|
}, waitTime);
|
||||||
// Limit incremental search to text types
|
|
||||||
else if (type !== "image") {
|
|
||||||
search(rerank=false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function populate_type_dropdown() {
|
function populate_type_dropdown() {
|
||||||
|
|||||||
Reference in New Issue
Block a user