import React, { memo, useEffect, useRef, useState } from 'react' import { Editor } from '@tiptap/react' import { useRouter } from 'next/router' import { sum } from 'lodash' import clsx from 'clsx' import { ContractComment } from 'common/comment' import { Contract } from 'common/contract' import { useUser } from 'web/hooks/use-user' import { formatMoney } from 'common/util/format' import { Row } from 'web/components/layout/row' import { Avatar } from 'web/components/avatar' import { OutcomeLabel } from 'web/components/outcome-label' import { CopyLinkDateTimeComponent } from 'web/components/feed/copy-link-date-time' import { firebaseLogin } from 'web/lib/firebase/users' import { createCommentOnContract } from 'web/lib/firebase/comments' import { Col } from 'web/components/layout/col' import { track } from 'web/lib/service/analytics' import { Tipper } from '../tipper' import { CommentTipMap } from 'web/hooks/use-tip-txns' import { useEvent } from 'web/hooks/use-event' import { Content } from '../editor' import { UserLink } from 'web/components/user-link' import { CommentInput } from '../comment-input' import { AwardBountyButton } from 'web/components/award-bounty-button' export type ReplyTo = { id: string; username: string } export function FeedCommentThread(props: { contract: Contract threadComments: ContractComment[] tips: CommentTipMap parentComment: ContractComment }) { const { contract, threadComments, tips, parentComment } = props const [replyTo, setReplyTo] = useState() const user = useUser() const onSubmitComment = useEvent(() => setReplyTo(undefined)) const onReplyClick = useEvent((comment: ContractComment) => { setReplyTo({ id: comment.id, username: comment.userUsername }) }) return (