diff --git a/src/app/dashboard/[subdomain]/comments/page.tsx b/src/app/dashboard/[subdomain]/comments/page.tsx index 6f4be148..4df79fc1 100644 --- a/src/app/dashboard/[subdomain]/comments/page.tsx +++ b/src/app/dashboard/[subdomain]/comments/page.tsx @@ -1,6 +1,7 @@ "use client" import { useParams } from "next/navigation" +import { useEffect } from "react" import { Virtuoso } from "react-virtuoso" import { CommentItem } from "~/components/common/CommentItem" @@ -21,6 +22,19 @@ export default function CommentsPage() { characterId: site.data?.characterId, }) + // fetch next page when we get a empty list + useEffect(() => { + if ( + comments.data?.pages && + comments.data.pages.at(-1)?.list.length === 0 && + comments.hasNextPage + ) { + comments.fetchNextPage() + } + }, [comments.data, comments.hasNextPage, comments.fetchNextPage]) + + const data = comments.data?.pages.filter((page) => page.list.length > 0) + const feedUrl = getSiteLink({ subdomain: subdomain, @@ -47,7 +61,7 @@ export default function CommentsPage() { comments.hasNextPage && comments.fetchNextPage() }