mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user