From 49cfbb9149fe1fc1235dbff165a2725f556571df Mon Sep 17 00:00:00 2001 From: dawn <90008@gaze.systems> Date: Thu, 01 Jan 2026 21:59:17 +0000 Subject: [PATCH] fix infinite loading bug if repo has no posts, fix build --- svelte.config.js | 5 ++++- src/components/TimelineView.svelte | 8 +++++++- src/lib/at/client.ts | 2 +- src/routes/[...catchall]/+page.ts | 2 ++ 4 file(s) changed, 14 insertion(s)(+), 3 deletion(s)(-) diff --git a/svelte.config.js b/svelte.config.js --- a/svelte.config.js +++ b/svelte.config.js @@ -11,7 +11,10 @@ // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. // If your environment is not supported, or you settled on a specific environment, switch out the adapter. // See https://svelte.dev/docs/kit/adapters for more information about adapters. - adapter: adapter(), + adapter: adapter({ + fallback: 'index.html', + precompress: true + }), alias: { $lib: 'src/lib', '$lib/*': 'src/lib/*', diff --git a/src/components/TimelineView.svelte b/src/components/TimelineView.svelte --- a/src/components/TimelineView.svelte +++ b/src/components/TimelineView.svelte @@ -80,7 +80,13 @@ }; $effect(() => { - if (threads.length === 0 && !loading && did) loadMore(); + if (threads.length === 0 && !loading && did) { + // if we saw all posts dont try to load more. + // this only really happens if the user has no posts at all + // but we do have to handle it to not cause an infinite loop + const cursor = did ? postCursors.get(did as AtprotoDid) : undefined; + if (!cursor?.end) loadMore(); + } if (client && did && fetchMoreInteractions) { // set to false so it doesnt attempt to fetch again while its already fetching fetchMoreInteractions = false; diff --git a/src/lib/at/client.ts b/src/lib/at/client.ts --- a/src/lib/at/client.ts +++ b/src/lib/at/client.ts @@ -196,7 +196,7 @@ if (!res.ok) return res; data.cursor = res.value.cursor; data.records.push(...res.value.records); - end = !data.cursor; + end = data.records.length === 0 || !data.cursor; if (!end && timestamp > 0) { const cursorTimestamp = timestampFromCursor(data.cursor); if (cursorTimestamp === undefined) { diff --git a/src/routes/[...catchall]/+page.ts b/src/routes/[...catchall]/+page.ts --- a/src/routes/[...catchall]/+page.ts +++ b/src/routes/[...catchall]/+page.ts @@ -5,6 +5,8 @@ import { err, ok, type Result } from '$lib/result'; import type { PageLoad } from './$types'; +export const prerender = false; + export type PageProps = { data: { client: Result; -- tangled.sh