Search optimization

This commit is contained in:
Eduard Urbach 2018-07-07 19:29:13 +09:00
parent daabaa3bd3
commit 558e756b53

View File

@ -126,6 +126,11 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, evt?:
.catch(console.error) .catch(console.error)
requestIdleCallback(() => { requestIdleCallback(() => {
// Check that the term hasn't changed in the meantime
if(term !== search.value.trim()) {
return
}
fetch("/_/character-search/" + term, fetchOptions) fetch("/_/character-search/" + term, fetchOptions)
.then(showResponseInElement(arn, url, "character", characterSearchResults)) .then(showResponseInElement(arn, url, "character", characterSearchResults))
.catch(console.error) .catch(console.error)