Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When typing quickly, can ignore the previous useless request? #153

Closed
yezige opened this issue Sep 19, 2024 · 9 comments · Fixed by #165
Closed

When typing quickly, can ignore the previous useless request? #153

yezige opened this issue Sep 19, 2024 · 9 comments · Fixed by #165

Comments

@yezige
Copy link

yezige commented Sep 19, 2024

When typing quickly, can ignore the previous useless request?

eg. I search forhains, and will search for ha,hai, andhains respectively.

@yezige
Copy link
Author

yezige commented Sep 19, 2024

I have an idea that I don't know if it can be realized, as follows:

var timeout
function oninput(s) {
  timeout && clearTimeout(timeout)
  timeout = setTimeout(() => {
    doquery(s)
  }, 500)
}
function doquery(s) {
  console.log(s)
}
oninput('ha')
oninput('hai')
oninput('hains')

setTimeout(() => {
  oninput('hains point')
}, 1000)

output:

hains
hains point

It can be seen that when typing quickly, only the real requirements:hains, hains point are successfully executed

@amrbashir
Copy link
Member

amrbashir commented Sep 19, 2024

We do debounce search queries, see

const debouncedSearch = utils.debounce(search, 100);
if (initialQuery) {
onMount(() => {
setQuery(initialQuery);
search(initialQuery);
});
}
function onInput(
e: InputEvent & {
currentTarget: HTMLInputElement;
target: Element;
},
) {
const query = e.currentTarget?.value;
setQuery(query);
if (!query) {
onReset();
return;
}
debouncedSearch(query);
}

it is 100ms though, not 500ms

@yezige
Copy link
Author

yezige commented Sep 20, 2024

Cool, maybe 100ms is too short.

@amrbashir
Copy link
Member

I will probably make this configurable instead.

@yezige
Copy link
Author

yezige commented Sep 20, 2024

Great, but I think 100ms is indeed too low, 500ms will be better, it seems that there is no need to change it to configurable, because everyone's needs are not much different.

@amrbashir
Copy link
Member

amrbashir commented Sep 20, 2024

from my previous testing, 500ms was a bit slow and noticeable specially when selecting some text on page then hitting the search hotkey.

@yezige
Copy link
Author

yezige commented Sep 20, 2024

Hmm, you need to decide the specific data. this time should be greater than the speed of normal people typing two letters.

@yezige
Copy link
Author

yezige commented Sep 20, 2024

加油老哥

amrbashir added a commit that referenced this issue Oct 14, 2024
amrbashir added a commit that referenced this issue Oct 14, 2024
@yezige
Copy link
Author

yezige commented Oct 14, 2024

太秀了,神速

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants