From 558e756b532e1f0ebff27b883c3eac46f5cfe306 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 7 Jul 2018 19:29:13 +0900 Subject: [PATCH] Search optimization --- scripts/Actions/Search.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/Actions/Search.ts b/scripts/Actions/Search.ts index 6355ffb6..102b4d29 100644 --- a/scripts/Actions/Search.ts +++ b/scripts/Actions/Search.ts @@ -126,6 +126,11 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, evt?: .catch(console.error) requestIdleCallback(() => { + // Check that the term hasn't changed in the meantime + if(term !== search.value.trim()) { + return + } + fetch("/_/character-search/" + term, fetchOptions) .then(showResponseInElement(arn, url, "character", characterSearchResults)) .catch(console.error)