import { useQuery } from '@apollo/client' import { MORE_FLAT_COMMENTS } from '../fragments/comments' import Comment, { CommentSkeleton } from './comment' import styles from './notifications.module.css' import { useRouter } from 'next/router' import MoreFooter from './more-footer' export default function CommentsFlat ({ variables, comments, cursor, ...props }) { const router = useRouter() const { data, fetchMore } = useQuery(MORE_FLAT_COMMENTS, { variables }) if (!data && !comments) { return } if (data) { ({ moreFlatComments: { comments, cursor } } = data) } return ( <> {comments.map(item => (
{ router.push({ pathname: '/items/[id]', query: { id: item.parentId, commentId: item.id } }, `/items/${item.parentId}`) }} >
))} ) } function CommentsFlatSkeleton () { const comments = new Array(21).fill(null) return (
{comments.map((_, i) => ( ))}
) }