import { Bet } from 'common/bet' import { ContractComment } from 'common/comment' import { PRESENT_BET, User } from 'common/user' import { Contract } from 'common/contract' import React, { useEffect, useState } from 'react' import { minBy, maxBy, partition, sumBy, Dictionary } from 'lodash' import { useUser } from 'web/hooks/use-user' import { formatMoney } from 'common/util/format' import { useRouter } from 'next/router' import { Row } from 'web/components/layout/row' import clsx from 'clsx' 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, CommentTips } from 'web/hooks/use-tip-txns' import { Content } from '../editor' import { Editor } from '@tiptap/react' import { UserLink } from 'web/components/user-link' import { CommentInput } from '../comment-input' export function FeedCommentThread(props: { user: User | null | undefined contract: Contract threadComments: ContractComment[] tips: CommentTipMap parentComment: ContractComment bets: Bet[] betsByUserId: Dictionary commentsByUserId: Dictionary }) { const { user, contract, threadComments, commentsByUserId, bets, betsByUserId, tips, parentComment, } = props const [showReply, setShowReply] = useState(false) const [replyTo, setReplyTo] = useState<{ id: string; username: string }>() function scrollAndOpenReplyInput(comment: ContractComment) { setReplyTo({ id: comment.userId, username: comment.userUsername }) setShowReply(true) } return (