mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-25 18:46:23 +00:00
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
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:
10153
web/package-lock.json
generated
Normal file
10153
web/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -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({
|
||||
|
Reference in New Issue
Block a user