+ {#if error}
+ {error}
+ {:else if Object.keys($generations).length > 0}
{#each Object.entries($generations).toSorted(sortTimeBuckets) as [category, items]}
{category}
@@ -74,19 +112,24 @@
{/each}
- {/if}
- {#if isFetching}
- 0 ? ' pt-8 border-t' : '')}
- >
- Fetching your creations
-
-
- {:else if Object.keys($generations).length === 0}
+ {#await fetchPromise}
+ 0 ? ' pt-8 border-t' : '')}
+ >
+ Fetching your creations
+
+
+ {:then}
+ {#if $nextPageTokens[$nextPageTokens.length - 1] === null}
+
+ You've reached the end of your creations 🎉
+
+ {/if}
+ {/await}
+ {:else}
You'll see your creations here once you submit your first prompt
{/if}
- {#if error}
- {error}
- {/if}
diff --git a/src/lib/consts.ts b/src/lib/consts.ts
index 2f35ccf..75734c0 100644
--- a/src/lib/consts.ts
+++ b/src/lib/consts.ts
@@ -1,6 +1,6 @@
import { msSinceStartOfDay, msSinceStartOfMonth, msSinceAWeekAgo, msSinceStartOfYear } from './time'
-export const PERSIST_KEY_VERSION = '2023-01-09'
+export const PERSIST_KEY_VERSION = '2024-06-21'
export const PERSIST_KEY_GENERATIONS = 'TEXT_TO_CAD_GENERATIONS'
export const PERSIST_KEY_UNREAD = 'TEXT_TO_CAD_UNREAD'
@@ -41,3 +41,12 @@ export const TIME_BUCKETS = [
test: (then: Date, now: Date) => now.getTime() - then.getTime() < msSinceStartOfYear(now)
}
] as const
+
+/**
+ * The number of pages to fetch ahead of the current page
+ */
+export const PAGES_AHEAD_TO_FETCH = 5
+/**
+ * The number of items to fetch per request
+ */
+export const ITEMS_PER_PAGE = 5
diff --git a/src/lib/endpoints.ts b/src/lib/endpoints.ts
index 42481ce..a4813ab 100644
--- a/src/lib/endpoints.ts
+++ b/src/lib/endpoints.ts
@@ -1,4 +1,5 @@
import type { Models } from '@kittycad/lib'
+import { ITEMS_PER_PAGE } from './consts'
export type CADFormat = Models['FileExportFormat_type']
@@ -23,7 +24,7 @@ export const endpoints = {
`${import.meta.env.VITE_API_BASE_URL}/file/conversion/gltf/${output_format}`,
feedback: (id: string, feedback: Models['TextToCad_type']['feedback']) =>
`${import.meta.env.VITE_API_BASE_URL}/user/text-to-cad/${id}?feedback=${feedback}`,
- list: ({ limit = 5, page_token }: ListParams) =>
+ list: ({ limit = ITEMS_PER_PAGE, page_token }: ListParams) =>
`${import.meta.env.VITE_API_BASE_URL}/user/text-to-cad?no_models=true&limit=${limit}${
page_token ? `&page_token=${page_token}` : ''
}`,
diff --git a/src/lib/stores.ts b/src/lib/stores.ts
index ea9dd14..0c9cade 100644
--- a/src/lib/stores.ts
+++ b/src/lib/stores.ts
@@ -55,7 +55,10 @@ export const generations = derived([combinedGenerations], ([$combinedGenerations
return groupBy($combinedGenerations, ({ created_at }) => bucketByTime(created_at))
})
-export const nextPageToken = writable