import Item, { ItemSkeleton } from './item' import Reply, { ReplySkeleton } from './reply' import Comment from './comment' import Text from './text' import Comments, { CommentsSkeleton } from './comments' import { COMMENTS } from '../fragments/comments' import { ITEM_FIELDS } from '../fragments/items' import { gql, useQuery } from '@apollo/client' import styles from '../styles/item.module.css' import { NOFOLLOW_LIMIT } from '../lib/constants' import { useRouter } from 'next/router' function BioItem ({ item }) { if (!item.text) { return null } return ( <> ) } function TopLevelItem ({ item }) { return ( {item.text && } ) } function ItemText ({ item }) { return {item.text} } export default function ItemFull ({ item: qItem, bio }) { const query = gql` ${ITEM_FIELDS} ${COMMENTS} { item(id: ${qItem.id}) { ...ItemFields text comments { ...CommentsRecursive } } }` const router = useRouter() const { error, data } = useQuery(query, { fetchPolicy: router.query.cache ? 'cache-first' : undefined }) if (error) return
Failed to load!
if (!data) { return (
) } const { item } = data return ( <> {item.parentId ? : (bio ? : )}
) }