import { Answer } from 'common/answer' import { FreeResponseContract } from 'common/contract' import { ContractComment } from 'common/comment' import React, { useEffect, useRef, useState } from 'react' import { sum } from 'lodash' import { Col } from 'web/components/layout/col' import { Row } from 'web/components/layout/row' import { Avatar } from 'web/components/avatar' import { Linkify } from 'web/components/linkify' import clsx from 'clsx' import { ContractCommentInput, FeedComment, ReplyTo, } from 'web/components/feed/feed-comments' import { CopyLinkDateTimeComponent } from 'web/components/feed/copy-link-date-time' import { useRouter } from 'next/router' import { useUser } from 'web/hooks/use-user' import { useEvent } from 'web/hooks/use-event' import { CommentTipMap } from 'web/hooks/use-tip-txns' import { UserLink } from 'web/components/user-link' export function FeedAnswerCommentGroup(props: { contract: FreeResponseContract answer: Answer answerComments: ContractComment[] tips: CommentTipMap }) { const { answer, contract, answerComments, tips } = props const { username, avatarUrl, name, text } = answer const [replyTo, setReplyTo] = useState() const user = useUser() const router = useRouter() const answerElementId = `answer-${answer.id}` const highlighted = router.asPath.endsWith(`#${answerElementId}`) const answerRef = useRef(null) const onSubmitComment = useEvent(() => setReplyTo(undefined)) const onReplyClick = useEvent((comment: ContractComment) => { setReplyTo({ id: comment.id, username: comment.userUsername }) }) useEffect(() => { if (highlighted && answerRef.current != null) { answerRef.current.scrollIntoView(true) } }, [highlighted]) return (
answered
{answerComments.map((comment) => ( ))} {replyTo && (
)} ) }