From 072f503ba66d79c6be52bf4ba6a05b62dfb8207c Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 17 Jun 2025 20:44:37 +0800 Subject: [PATCH] refactor(feed): optimize feed display and error handling - Introduced a constant `SIZE` to manage the number of feeds displayed, improving maintainability. - Updated the feed count display to use `list.data.feedCount` for accuracy. - Enhanced error handling in `callNotFound` to specifically manage `FetchError` instances, improving robustness. These changes aim to streamline feed management and enhance error reporting in the application. Signed-off-by: Innei --- apps/ssr/client/pages/(main)/share/lists/[id]/index.tsx | 9 ++++++--- .../ssr/client/pages/(main)/share/users/[id]/metadata.ts | 2 +- apps/ssr/src/lib/not-found.ts | 9 +++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/ssr/client/pages/(main)/share/lists/[id]/index.tsx b/apps/ssr/client/pages/(main)/share/lists/[id]/index.tsx index 6704da2ef..68927a094 100644 --- a/apps/ssr/client/pages/(main)/share/lists/[id]/index.tsx +++ b/apps/ssr/client/pages/(main)/share/lists/[id]/index.tsx @@ -48,6 +48,8 @@ const FeedRow = memo<{ feed: Feed["feed"] }>(({ feed }) => { ) }) +// Backend limit +const SIZE = 5 FeedRow.displayName = "FeedRow" export function Component() { @@ -142,7 +144,7 @@ export function Component() {
- {list.data.list.feedIds?.length || 0} + {list.data.feedCount || 0}
{(list.data.list.feedIds?.length || 0) > 1 ? "Feeds" : "Feed"} @@ -189,13 +191,14 @@ export function Component() {
{listData.feedIds - ?.slice(0, 7) + ?.slice(0, SIZE) .map((feedId) => )}
- {"feedCount" in list.data && list.data.feedCount > 7 && ( + {"feedCount" in list.data && list.data.feedCount > SIZE && (