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/lib/api.ts | 2 +- src/routes/auctionprices.svelte | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/api.ts b/src/lib/api.ts index 1721d01..e3559e1 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -1,3 +1,3 @@ // the trailing slash is required export const API_URL = 'https://skyblock-api.matdoes.dev/' -// export const API_URL = 'http://localhost:8080/' +// export const API_URL = 'http://localhost:8080/' \ No newline at end of file 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