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