perf(replies): progressive render, 500 replies/page, content-visibility

Set repliesPerPage to 500 to avoid Virtuoso pagination sort drift. Add useProgressiveRender with startTransition batching and CSS content-visibility for long reply lists.
This commit is contained in:
plebeius
2026-02-15 18:46:49 +08:00
parent ec620238e3
commit dedf18e199
5 changed files with 90 additions and 2 deletions
+11 -1
View File
@@ -37,6 +37,8 @@ import useFeedResetStore from '../../stores/use-feed-reset-store';
import usePostNumberStore from '../../stores/use-post-number-store';
import { alertChallengeVerificationFailed } from '../../lib/utils/challenge-utils';
import useQuotedByMap from '../../hooks/use-quoted-by-map';
import useProgressiveRender from '../../hooks/use-progressive-render';
import { REPLIES_PER_PAGE } from '../../lib/constants';
const { addChallenge } = useChallengesStore.getState();
@@ -497,6 +499,7 @@ const PostMobile = ({
comment: post,
sortType: 'old',
flat: true,
repliesPerPage: REPLIES_PER_PAGE,
accountComments: { newerThan: Infinity, append: true },
});
const { replies, hasMore, loadMore } = repliesResult;
@@ -537,6 +540,13 @@ const PostMobile = ({
const quotedByMap = useQuotedByMap(filteredReplies);
const visibleReplies = useProgressiveRender(filteredReplies, {
batchSize: 50,
intervalMs: 100,
resetKey: cid,
disabled: hasMore || !!targetReplyCid || !showAllReplies,
});
// Virtuoso scroll position management for infinite replies
const virtuosoRef = useRef<VirtuosoHandle | null>(null);
const virtuosoStateKey = `replies-mobile-${cid}`;
@@ -670,7 +680,7 @@ const PostMobile = ({
!isInPendingPostView &&
showReplies &&
!hasMore &&
filteredReplies.map((reply, index) => (
visibleReplies.map((reply, index) => (
<div key={index} className={styles.replyContainer}>
<Reply postReplyCount={replyCount} reply={reply} roles={roles} threadNumber={post?.number} quotedByMap={quotedByMap} />
</div>