mirror of
https://github.com/xvvvyz/tilde.git
synced 2026-03-11 14:44:24 +00:00
do not render suggestions for an old query
This commit is contained in:
parent
a6d2cf6bad
commit
d55fdb8bab
1 changed files with 9 additions and 7 deletions
16
index.html
16
index.html
|
|
@ -647,22 +647,24 @@
|
|||
}
|
||||
|
||||
#onInput = async () => {
|
||||
const q = Search.#parseQuery(this.#refs.input.value);
|
||||
const oq = Search.#parseQuery(this.#refs.input.value);
|
||||
|
||||
if (!q.query) {
|
||||
if (!oq.query) {
|
||||
this.#close();
|
||||
return;
|
||||
}
|
||||
|
||||
let suggestions = COMMANDS.get(q.query)?.suggestions ?? [];
|
||||
let suggestions = COMMANDS.get(oq.query)?.suggestions ?? [];
|
||||
|
||||
if (q.search && suggestions.length < CONFIG.suggestionLimit) {
|
||||
const res = await Search.#fetchDuckDuckGoSuggestions(q.search);
|
||||
const formatted = Search.#attachSearchPrefix(res, q);
|
||||
if (oq.search && suggestions.length < CONFIG.suggestionLimit) {
|
||||
const res = await Search.#fetchDuckDuckGoSuggestions(oq.search);
|
||||
const formatted = Search.#attachSearchPrefix(res, oq);
|
||||
suggestions = suggestions.concat(formatted);
|
||||
}
|
||||
|
||||
this.#renderSuggestions(suggestions, q.query);
|
||||
const nq = Search.#parseQuery(this.#refs.input.value);
|
||||
if (nq.query !== oq.query) return;
|
||||
this.#renderSuggestions(suggestions, oq.query);
|
||||
};
|
||||
|
||||
#onKeydown = (e) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue