From cc243a1dc23b4be3b4e707d4ebead381ae3ed4c5 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sat, 17 Mar 2018 22:20:26 +0100 Subject: [PATCH] Skip search request on whitespace change --- scripts/Actions/Search.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/Actions/Search.ts b/scripts/Actions/Search.ts index e3e93b41..2846faf5 100644 --- a/scripts/Actions/Search.ts +++ b/scripts/Actions/Search.ts @@ -12,6 +12,9 @@ var correctResponseRendered = { "company": false } +// Save old term to compare +var oldTerm = "" + // Containers for all the search results var animeSearchResults: HTMLElement var characterSearchResults: HTMLElement @@ -26,7 +29,16 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: Ke return } + // Check if the search term really changed let term = search.value.trim() + + if(term === oldTerm) { + return + } + + oldTerm = term + + // Determine if we're already seeing the search page let searchPageActivated = (searchPage === arn.app.content.children[0]) // Reset