From 75b66516fe72b90757dece4648a0b610341b6878 Mon Sep 17 00:00:00 2001 From: plebeius Date: Sun, 1 Mar 2026 18:36:12 +0800 Subject: [PATCH] refactor(replies): remove pinned-thread special handling for reply preview --- src/components/post-desktop/post-desktop.tsx | 4 +--- src/components/post-mobile/post-mobile.tsx | 8 +++----- src/lib/utils/replies-preview-utils.ts | 10 +++------- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/components/post-desktop/post-desktop.tsx b/src/components/post-desktop/post-desktop.tsx index 9e423dc9..c46d3a12 100644 --- a/src/components/post-desktop/post-desktop.tsx +++ b/src/components/post-desktop/post-desktop.tsx @@ -831,9 +831,8 @@ const PostDesktop = ({ const repliesCount = computeOmittedCount({ totalReplyCount, visibleCount: BOARD_REPLIES_PREVIEW_VISIBLE_COUNT, - pinned, }); - const linksCount = pinned ? totalLinksCount : totalLinksCount - visiblelinksCount; + const linksCount = totalLinksCount - visiblelinksCount; const stateString = useStateString(post) || t('downloading_board'); const hasFailedState = state === 'failed'; @@ -1056,7 +1055,6 @@ const PostDesktop = ({ {/* Non-virtualized rendering for board view (preview replies when collapsed, full when expanded) */} {!isHidden && !showAllReplies && - !(pinned && !isInPostPageView && !showOmittedReplies[cid]) && !isInPendingPostView && repliesForRender && showReplies && diff --git a/src/components/post-mobile/post-mobile.tsx b/src/components/post-mobile/post-mobile.tsx index 745e74e7..b1a0442a 100644 --- a/src/components/post-mobile/post-mobile.tsx +++ b/src/components/post-mobile/post-mobile.tsx @@ -732,7 +732,7 @@ const PostMobile = ({ )} {/* Virtuoso infinite scroll for post page view when there's more content to paginate */} - {!(pinned && !isInPostView) && showAllReplies && !isInPendingPostView && showReplies && hasMore && ( + {showAllReplies && !isInPendingPostView && showReplies && hasMore && ( )} {/* Non-virtualized rendering for post page view when all replies fit on one page */} - {!(pinned && !isInPostView) && - showAllReplies && + {showAllReplies && !isInPendingPostView && showReplies && !hasMore && @@ -776,8 +775,7 @@ const PostMobile = ({ ))} {/* Non-virtualized rendering for board view (last 5 replies) */} - {!(pinned && !isInPostView) && - !showAllReplies && + {!showAllReplies && !isInPendingPostView && repliesForRender && showReplies && diff --git a/src/lib/utils/replies-preview-utils.ts b/src/lib/utils/replies-preview-utils.ts index 962e0f71..ce78ef49 100644 --- a/src/lib/utils/replies-preview-utils.ts +++ b/src/lib/utils/replies-preview-utils.ts @@ -34,18 +34,14 @@ export function getPreviewDisplayReplies(replies: T[], vi export interface ComputeOmittedParams { totalReplyCount: number; visibleCount: number; - pinned?: boolean; } /** - * Computes omitted reply count for board view. For pinned threads, collapsed view - * shows 0 replies, so omitted = total. For non-pinned, omitted = total - visible. + * Computes omitted reply count for board view. All threads (pinned or not) show + * the last `visibleCount` replies when collapsed; omitted = total - visible. * Result is always clamped at zero. */ -export function computeOmittedCount({ totalReplyCount, visibleCount, pinned = false }: ComputeOmittedParams): number { - if (pinned) { - return Math.max(0, totalReplyCount); - } +export function computeOmittedCount({ totalReplyCount, visibleCount }: ComputeOmittedParams): number { return Math.max(0, totalReplyCount - visibleCount); }