diff --git a/src/routes/(info)/lttstore/+page.server.ts b/src/routes/(info)/lttstore/+page.server.ts index 0613da6..e240a42 100644 --- a/src/routes/(info)/lttstore/+page.server.ts +++ b/src/routes/(info)/lttstore/+page.server.ts @@ -12,10 +12,6 @@ export const load = (async ({platform}) => { if(dev) await createTables(db) - /*const allProducts = db.prepare("select id,handle,title,json_extract(product, '$.featured_image') as featured_image, available from products") - .all() - .then(r => r.results);*/ // was used for local search index. No longer needed. - const popularProducts = db.prepare("select * from products order by purchasesPerHour DESC limit 11") .all() .then(r => r.results); @@ -48,12 +44,11 @@ export const load = (async ({platform}) => { } return { - // allProducts: await allProducts, - popularProducts: await popularProducts, - lowStock: await lowStock, - onSale: await onSale, newProducts, - recentRestocks: await recentRestocks + popularProducts: await popularProducts, + lowStock, + onSale, + recentRestocks } }) satisfies PageServerLoad diff --git a/src/routes/(info)/lttstore/+page.svelte b/src/routes/(info)/lttstore/+page.svelte index 7fa07d2..f62a952 100644 --- a/src/routes/(info)/lttstore/+page.svelte +++ b/src/routes/(info)/lttstore/+page.svelte @@ -86,6 +86,11 @@ await invalidateAll() loading = false; } + + let mounted = false; + onMount(() => { + setTimeout(() => mounted = true, 0) + }); LTTStore Watcher - Whenplane @@ -103,7 +108,7 @@ -
+
@@ -197,41 +202,59 @@

- {#if data.onSale.length > 0} -

On Sale

-
- These products are currently on sale. (excludes items that are out of stock) -
- {#each data.onSale as product} - - {/each} -
-
- {/if} + {#await data.onSale} +
+ {:then onSale} + {#if onSale.length > 0 && mounted} +
+

On Sale

+
+ These products are currently on sale. (excludes items that are out of stock) +
+ {#each onSale as product} + + {/each} +
+
+
+ {/if} + {/await} - {#if data.lowStock.length > 0} -

Low Stock

-
- These items are low in stock and selling fast enough to possibly run out of stock soon. -
- {#each data.lowStock as product} - - {/each} -
-
- {/if} + {#await data.lowStock} +
+ {:then lowStock} + {#if lowStock.length > 0 && mounted} +
+

Low Stock

+
+ These items are low in stock and selling fast enough to possibly run out of stock soon. +
+ {#each lowStock as product} + + {/each} +
+
+
+ {/if} + {/await} - {#if data.recentRestocks.length > 0} -

Recently Re-stocked

-
- These items have been restocked in the past 6 days. -
- {#each data.recentRestocks as product} - - {/each} -
-
- {/if} + {#await data.recentRestocks} +
+ {:then recentRestocks} + {#if recentRestocks.length > 0 && mounted} +
+

Recently Re-stocked

+
+ These items have been restocked in the past 6 days. +
+ {#each recentRestocks as product} + + {/each} +
+
+
+ {/if} + {/await}