Merge pull request #16 from snowykami/copilot/fix-60cc94a6-e38d-41c7-88cc-4697e65463f6
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 13s

Fix comment pagination bug - prevent comments from disappearing on load more
This commit is contained in:
2025-09-22 10:39:04 +08:00
committed by GitHub
2 changed files with 10163 additions and 2 deletions

10153
web/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -34,19 +34,27 @@ export function CommentSection(
const [needLoadMore, setNeedLoadMore] = useState(true); // 是否需要加载更多当最后一次获取的评论数小于分页大小时设为false
// 加载0/顶层评论
useEffect(() => {
// Reset pagination state when target changes
setPage(1);
setNeedLoadMore(true);
listComments({
targetType,
targetId,
depth: 0,
orderBy: OrderBy.CreatedAt,
desc: true,
page: page,
page: 1,
size: config.commentsPerPage,
commentId: 0
}).then(response => {
setComments(response.data.comments);
// If we got fewer comments than requested, no more pages
if (response.data.comments.length < config.commentsPerPage) {
setNeedLoadMore(false);
}
});
}, [page, targetId, targetType]);
}, [targetId, targetType]);
const onCommentSubmitted = ({ commentContent, isPrivate, showClientInfo }: { commentContent: string, isPrivate: boolean, showClientInfo: boolean }) => {
createComment({