From 257fc6da4055e153e4cc57ef65ffe34db5b10e09 Mon Sep 17 00:00:00 2001 From: Bretton Date: Sun, 22 Feb 2026 13:47:33 -0800 Subject: [PATCH] feat(feed): fix pagination, auth error handling, and empty states Thread loadFeed callback through PostListShell and VirtualFeed to restore infinite scroll pagination on home and community pages. Add auth error detection (401/403) that shows session-expired message with login button. Improve feed robustness with null-safe responses, cursor-based hasMore logic, and proper error re-throwing. Changes: - Add loadFeed prop to PostListShell and pass to VirtualFeed - Create loadFeed functions in home and community page loaders - Detect XrpcError 401/403 and show login prompt instead of retry - Move loading=false to finally block in VirtualFeed - Guard against null feed responses with ?? [] - Add empty state placeholder on home page - Fix /communities link to /explore/communities - Update empty feed description copy Co-Authored-By: Claude Opus 4.6 --- src/lib/app/i18n/en.json | 2 +- src/lib/feature/feeds/feed.svelte.ts | 1 + src/lib/feature/post/feed/VirtualFeed.svelte | 48 +++++++++++++------- src/lib/ui/layout/pages/PostListShell.svelte | 6 ++- src/routes/+page.svelte | 27 ++++++++++- src/routes/+page.ts | 39 ++++++++-------- src/routes/c/[handle]/+page.svelte | 1 + src/routes/c/[handle]/+page.ts | 10 +++- 8 files changed, 94 insertions(+), 40 deletions(-) diff --git a/src/lib/app/i18n/en.json b/src/lib/app/i18n/en.json index eb749b12..0b01a517 100644 --- a/src/lib/app/i18n/en.json +++ b/src/lib/app/i18n/en.json @@ -236,7 +236,7 @@ "endFeed": "You have reached the end of {{community_name; undefined:the feed.; default:{{community_name}}.}}", "empty": { "title": "No posts", - "description": "There are no posts that match this filter." + "description": "There are no posts in this feed." } }, "modlog": { diff --git a/src/lib/feature/feeds/feed.svelte.ts b/src/lib/feature/feeds/feed.svelte.ts index 0e718422..692918eb 100644 --- a/src/lib/feature/feeds/feed.svelte.ts +++ b/src/lib/feature/feeds/feed.svelte.ts @@ -46,6 +46,7 @@ export class Feed { } catch (err) { console.error('[Feed] fetch failed:', err) this.error = err + throw err } } diff --git a/src/lib/feature/post/feed/VirtualFeed.svelte b/src/lib/feature/post/feed/VirtualFeed.svelte index fae46f22..e5b80b23 100644 --- a/src/lib/feature/post/feed/VirtualFeed.svelte +++ b/src/lib/feature/post/feed/VirtualFeed.svelte @@ -1,5 +1,6 @@