aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-05-18 21:12:45 +0000
committermat <github@matdoes.dev>2022-05-18 21:12:45 +0000
commit05bca625f53f021596bc8e84fb7ee6933114a65a (patch)
treed2bd965db3af6717710130715c92aa36a5a2711b /src
parentbe6907cfa459c850e7b200df91d8347a39bfe614 (diff)
downloadskyblock-stats-05bca625f53f021596bc8e84fb7ee6933114a65a.tar.gz
skyblock-stats-05bca625f53f021596bc8e84fb7ee6933114a65a.tar.bz2
skyblock-stats-05bca625f53f021596bc8e84fb7ee6933114a65a.zip
show 'no results' faster
Diffstat (limited to 'src')
-rw-r--r--src/lib/api.ts2
-rw-r--r--src/routes/auctionprices.svelte7
2 files changed, 6 insertions, 3 deletions
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<ItemAuctionsSchema[]> {
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
}