From 52293d3ced2b3a3e883a4f1f8499cfa72c2745b1 Mon Sep 17 00:00:00 2001 From: mat Date: Tue, 17 May 2022 23:47:15 -0500 Subject: fix race condition in search --- src/routes/auctionprices.svelte | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/routes/auctionprices.svelte b/src/routes/auctionprices.svelte index 33b6b86..b8ac429 100644 --- a/src/routes/auctionprices.svelte +++ b/src/routes/auctionprices.svelte @@ -43,9 +43,13 @@ } async function fetchItems(itemIds: string[]) { - let url = `${API_URL}auctionprices` + const url = `${API_URL}auctionprices` + const localQuery = query if (query.length > 0) url += `?items=${itemIds.join(',')}` - data = await fetch(url).then(r => r.json()) + const localData = await fetch(url).then(r => r.json()) + + // if the query hasn't changed, update the data + if (query === localQuery) data = localData } let pageHeight = 0 -- cgit