perf(feeds): use hasMore instead of length check for conditional virtualization

This commit is contained in:
plebeius
2026-01-13 17:01:51 +01:00
parent 80100fa54d
commit c0c6e9ee31
5 changed files with 54 additions and 34 deletions
+4 -4
View File
@@ -498,8 +498,8 @@ const PostDesktop = ({ post, roles, showAllReplies, showReplies = true }: PostPr
)}
</span>
)}
{/* Virtuoso infinite scroll for post page view with more than 25 replies */}
{!isHidden && showAllReplies && !isInPendingPostView && showReplies && replyCount > 25 && (
{/* Virtuoso infinite scroll for post page view when there's more content to paginate */}
{!isHidden && showAllReplies && !isInPendingPostView && showReplies && hasMore && (
<Virtuoso
increaseViewportBy={{ bottom: 1200, top: 1200 }}
totalCount={filteredReplies.length}
@@ -517,12 +517,12 @@ const PostDesktop = ({ post, roles, showAllReplies, showReplies = true }: PostPr
initialScrollTop={lastVirtuosoState?.scrollTop}
/>
)}
{/* Non-virtualized rendering for post page view with 25 or fewer replies */}
{/* Non-virtualized rendering for post page view when all replies fit on one page */}
{!isHidden &&
showAllReplies &&
!isInPendingPostView &&
showReplies &&
replyCount <= 25 &&
!hasMore &&
filteredReplies.map((reply, index) => (
<div key={index} className={styles.replyContainer}>
<Reply reply={reply} roles={roles} postReplyCount={replyCount} threadNumber={post?.number} />
+4 -4
View File
@@ -374,8 +374,8 @@ const PostMobile = ({ post, roles, showAllReplies, showReplies = true }: PostPro
</div>
)}
</div>
{/* Virtuoso infinite scroll for post page view with more than 25 replies */}
{!(pinned && !isInPostView) && showAllReplies && !isInPendingPostView && showReplies && replyCount > 25 && (
{/* Virtuoso infinite scroll for post page view when there's more content to paginate */}
{!(pinned && !isInPostView) && showAllReplies && !isInPendingPostView && showReplies && hasMore && (
<Virtuoso
increaseViewportBy={{ bottom: 1200, top: 1200 }}
totalCount={filteredReplies.length}
@@ -393,12 +393,12 @@ const PostMobile = ({ post, roles, showAllReplies, showReplies = true }: PostPro
initialScrollTop={lastVirtuosoState?.scrollTop}
/>
)}
{/* Non-virtualized rendering for post page view with 25 or fewer replies */}
{/* Non-virtualized rendering for post page view when all replies fit on one page */}
{!(pinned && !isInPostView) &&
showAllReplies &&
!isInPendingPostView &&
showReplies &&
replyCount <= 25 &&
!hasMore &&
filteredReplies.map((reply, index) => (
<div key={index} className={styles.replyContainer}>
<Reply postReplyCount={replyCount} reply={reply} roles={roles} threadNumber={post?.number} />