mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
refactor(replies): remove pinned-thread special handling for reply preview
This commit is contained in:
@@ -831,9 +831,8 @@ const PostDesktop = ({
|
|||||||
const repliesCount = computeOmittedCount({
|
const repliesCount = computeOmittedCount({
|
||||||
totalReplyCount,
|
totalReplyCount,
|
||||||
visibleCount: BOARD_REPLIES_PREVIEW_VISIBLE_COUNT,
|
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 stateString = useStateString(post) || t('downloading_board');
|
||||||
const hasFailedState = state === 'failed';
|
const hasFailedState = state === 'failed';
|
||||||
@@ -1056,7 +1055,6 @@ const PostDesktop = ({
|
|||||||
{/* Non-virtualized rendering for board view (preview replies when collapsed, full when expanded) */}
|
{/* Non-virtualized rendering for board view (preview replies when collapsed, full when expanded) */}
|
||||||
{!isHidden &&
|
{!isHidden &&
|
||||||
!showAllReplies &&
|
!showAllReplies &&
|
||||||
!(pinned && !isInPostPageView && !showOmittedReplies[cid]) &&
|
|
||||||
!isInPendingPostView &&
|
!isInPendingPostView &&
|
||||||
repliesForRender &&
|
repliesForRender &&
|
||||||
showReplies &&
|
showReplies &&
|
||||||
|
|||||||
@@ -732,7 +732,7 @@ const PostMobile = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{/* Virtuoso infinite scroll for post page view when there's more content to paginate */}
|
{/* Virtuoso infinite scroll for post page view when there's more content to paginate */}
|
||||||
{!(pinned && !isInPostView) && showAllReplies && !isInPendingPostView && showReplies && hasMore && (
|
{showAllReplies && !isInPendingPostView && showReplies && hasMore && (
|
||||||
<Virtuoso
|
<Virtuoso
|
||||||
increaseViewportBy={{ bottom: 1200, top: 1200 }}
|
increaseViewportBy={{ bottom: 1200, top: 1200 }}
|
||||||
totalCount={filteredReplies.length}
|
totalCount={filteredReplies.length}
|
||||||
@@ -758,8 +758,7 @@ const PostMobile = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{/* Non-virtualized rendering for post page view when all replies fit on one page */}
|
{/* Non-virtualized rendering for post page view when all replies fit on one page */}
|
||||||
{!(pinned && !isInPostView) &&
|
{showAllReplies &&
|
||||||
showAllReplies &&
|
|
||||||
!isInPendingPostView &&
|
!isInPendingPostView &&
|
||||||
showReplies &&
|
showReplies &&
|
||||||
!hasMore &&
|
!hasMore &&
|
||||||
@@ -776,8 +775,7 @@ const PostMobile = ({
|
|||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{/* Non-virtualized rendering for board view (last 5 replies) */}
|
{/* Non-virtualized rendering for board view (last 5 replies) */}
|
||||||
{!(pinned && !isInPostView) &&
|
{!showAllReplies &&
|
||||||
!showAllReplies &&
|
|
||||||
!isInPendingPostView &&
|
!isInPendingPostView &&
|
||||||
repliesForRender &&
|
repliesForRender &&
|
||||||
showReplies &&
|
showReplies &&
|
||||||
|
|||||||
@@ -34,18 +34,14 @@ export function getPreviewDisplayReplies<T extends CommentLike>(replies: T[], vi
|
|||||||
export interface ComputeOmittedParams {
|
export interface ComputeOmittedParams {
|
||||||
totalReplyCount: number;
|
totalReplyCount: number;
|
||||||
visibleCount: number;
|
visibleCount: number;
|
||||||
pinned?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes omitted reply count for board view. For pinned threads, collapsed view
|
* Computes omitted reply count for board view. All threads (pinned or not) show
|
||||||
* shows 0 replies, so omitted = total. For non-pinned, omitted = total - visible.
|
* the last `visibleCount` replies when collapsed; omitted = total - visible.
|
||||||
* Result is always clamped at zero.
|
* Result is always clamped at zero.
|
||||||
*/
|
*/
|
||||||
export function computeOmittedCount({ totalReplyCount, visibleCount, pinned = false }: ComputeOmittedParams): number {
|
export function computeOmittedCount({ totalReplyCount, visibleCount }: ComputeOmittedParams): number {
|
||||||
if (pinned) {
|
|
||||||
return Math.max(0, totalReplyCount);
|
|
||||||
}
|
|
||||||
return Math.max(0, totalReplyCount - visibleCount);
|
return Math.max(0, totalReplyCount - visibleCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user