From 05bca625f53f021596bc8e84fb7ee6933114a65a Mon Sep 17 00:00:00 2001 From: mat Date: Wed, 18 May 2022 21:12:45 +0000 Subject: show 'no results' faster --- src/routes/auctionprices.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/routes') diff --git a/src/routes/auctionprices.svelte b/src/routes/auctionprices.svelte index 0ef7d3f..3c57e1e 100644 --- a/src/routes/auctionprices.svelte +++ b/src/routes/auctionprices.svelte @@ -55,7 +55,10 @@ } async function fetchItems(itemIds: null | string[]): Promise { let url = `${API_URL}auctionprices` - if (itemIds !== null) url += `?items=${itemIds.join(',')}` + if (itemIds !== null) { + if (itemIds.length === 0) return [] + url += `?items=${itemIds.join(',')}` + } return await fetch(url).then(r => r.json()) } @@ -81,7 +84,7 @@ if (itemIds.length > 0) { const shownIds = data.map(d => d.id) const items = (await fetchItems(itemIds)).filter(i => !shownIds.includes(i.id)) - data = [...data, ...items] + if (items.length > 0) data = [...data, ...items] } loadingPage = false } -- cgit