import itemStyles from './item.module.css' import styles from './comment.module.css' import Text from './text' import Link from 'next/link' import Reply from './reply' import { useState } from 'react' import { gql, useQuery } from '@apollo/client' import { timeSince } from '../lib/time' import UpVote from './upvote' import Eye from '../svgs/eye-fill.svg' import EyeClose from '../svgs/eye-close-line.svg' function Parent ({ item }) { const { data } = useQuery( gql`{ root(id: ${item.id}) { id title } }` ) const ParentFrag = () => ( <> \ parent ) if (!data) { return } return ( <> {data.root.id !== item.parentId && } \ {data.root.title} ) } export default function Comment ({ item, children, replyOpen, includeParent, cacheId, noComments, noReply }) { const [reply, setReply] = useState(replyOpen) const [collapse, setCollapse] = useState(false) return (
{item.sats} sats \ {item.boost} boost \ {item.ncomments} replies \ @{item.user.name} {timeSince(new Date(item.createdAt))} {includeParent && }
{!includeParent && (collapse ? setCollapse(false)} /> : setCollapse(true)} />)}
{item.text}
{!noReply &&
setReply(!reply)} > {reply ? 'cancel' : 'reply'}
} {reply &&
setReply(replyOpen || false)} cacheId={cacheId} />
} {children}
{item.comments && !noComments ? item.comments.map((item) => ( )) : null}
) } export function CommentSkeleton ({ skeletonChildren }) { return (
{skeletonChildren ? : null}
) }