i don't even know
This commit is contained in:
		
							parent
							
								
									c8d2e19c3e
								
							
						
					
					
						commit
						1b1634ce8b
					
				| 
						 | 
					@ -4,7 +4,11 @@ import { Pagination } from 'web/components/pagination'
 | 
				
			||||||
import { FeedBet } from '../feed/feed-bets'
 | 
					import { FeedBet } from '../feed/feed-bets'
 | 
				
			||||||
import { FeedLiquidity } from '../feed/feed-liquidity'
 | 
					import { FeedLiquidity } from '../feed/feed-liquidity'
 | 
				
			||||||
import { CommentsAnswer } from '../feed/feed-answer-comment-group'
 | 
					import { CommentsAnswer } from '../feed/feed-answer-comment-group'
 | 
				
			||||||
import { FeedCommentThread, ContractCommentInput } from '../feed/feed-comments'
 | 
					import {
 | 
				
			||||||
 | 
					  FeedCommentThread,
 | 
				
			||||||
 | 
					  ContractCommentInput,
 | 
				
			||||||
 | 
					  CommentActions,
 | 
				
			||||||
 | 
					} from '../feed/feed-comments'
 | 
				
			||||||
import { groupBy, sortBy, sum } from 'lodash'
 | 
					import { groupBy, sortBy, sum } from 'lodash'
 | 
				
			||||||
import { Bet } from 'common/bet'
 | 
					import { Bet } from 'common/bet'
 | 
				
			||||||
import { Contract } from 'common/contract'
 | 
					import { Contract } from 'common/contract'
 | 
				
			||||||
| 
						 | 
					@ -42,7 +46,7 @@ import { Avatar } from '../avatar'
 | 
				
			||||||
import { UserLink } from '../user-link'
 | 
					import { UserLink } from '../user-link'
 | 
				
			||||||
import { CopyLinkDateTimeComponent } from '../feed/copy-link-date-time'
 | 
					import { CopyLinkDateTimeComponent } from '../feed/copy-link-date-time'
 | 
				
			||||||
import { Linkify } from '../linkify'
 | 
					import { Linkify } from '../linkify'
 | 
				
			||||||
import { ArrowRightIcon } from '@heroicons/react/solid'
 | 
					import { ArrowRightIcon, ReplyIcon } from '@heroicons/react/solid'
 | 
				
			||||||
import Curve from 'web/public/custom-components/curve'
 | 
					import Curve from 'web/public/custom-components/curve'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function ContractTabs(props: {
 | 
					export function ContractTabs(props: {
 | 
				
			||||||
| 
						 | 
					@ -172,9 +176,11 @@ const CommentsTabContent = memo(function CommentsTabContent(props: {
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
              return (
 | 
					              return (
 | 
				
			||||||
                <>
 | 
					                <>
 | 
				
			||||||
 | 
					                  <Row className="gap-2">
 | 
				
			||||||
                    <CommentsAnswer answer={answer} contract={contract} />
 | 
					                    <CommentsAnswer answer={answer} contract={contract} />
 | 
				
			||||||
 | 
					                  </Row>
 | 
				
			||||||
                  <Row>
 | 
					                  <Row>
 | 
				
			||||||
                    <div className="ml-2">
 | 
					                    <div className="ml-1">
 | 
				
			||||||
                      <Curve size={28} strokeWidth={1} color="#B1B1C7" />
 | 
					                      <Curve size={28} strokeWidth={1} color="#B1B1C7" />
 | 
				
			||||||
                    </div>
 | 
					                    </div>
 | 
				
			||||||
                    <div className="w-full pt-1">
 | 
					                    <div className="w-full pt-1">
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,24 +1,10 @@
 | 
				
			||||||
import { Answer } from 'common/answer'
 | 
					import { Answer } from 'common/answer'
 | 
				
			||||||
import { Contract, FreeResponseContract } from 'common/contract'
 | 
					import { Contract } from 'common/contract'
 | 
				
			||||||
import { ContractComment } from 'common/comment'
 | 
					 | 
				
			||||||
import React, { useEffect, useRef, useState } from 'react'
 | 
					 | 
				
			||||||
import { Col } from 'web/components/layout/col'
 | 
					import { Col } from 'web/components/layout/col'
 | 
				
			||||||
import { Row } from 'web/components/layout/row'
 | 
					import { Row } from 'web/components/layout/row'
 | 
				
			||||||
import { Avatar } from 'web/components/avatar'
 | 
					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 { CopyLinkDateTimeComponent } from 'web/components/feed/copy-link-date-time'
 | 
				
			||||||
import { useRouter } from 'next/router'
 | 
					 | 
				
			||||||
import { CommentTipMap } from 'web/hooks/use-tip-txns'
 | 
					 | 
				
			||||||
import { UserLink } from 'web/components/user-link'
 | 
					import { UserLink } from 'web/components/user-link'
 | 
				
			||||||
import TriangleDownFillIcon from 'web/lib/icons/triangle-down-fill-icon'
 | 
					 | 
				
			||||||
import { ReplyToggle } from '../comments/comments'
 | 
					 | 
				
			||||||
import { ReplyIcon } from '@heroicons/react/solid'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function CommentsAnswer(props: { answer: Answer; contract: Contract }) {
 | 
					export function CommentsAnswer(props: { answer: Answer; contract: Contract }) {
 | 
				
			||||||
  const { answer, contract } = props
 | 
					  const { answer, contract } = props
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ import { CommentInput } from '../comment-input'
 | 
				
			||||||
import { AwardBountyButton } from 'web/components/award-bounty-button'
 | 
					import { AwardBountyButton } from 'web/components/award-bounty-button'
 | 
				
			||||||
import { ReplyIcon } from '@heroicons/react/solid'
 | 
					import { ReplyIcon } from '@heroicons/react/solid'
 | 
				
			||||||
import { Button } from '../button'
 | 
					import { Button } from '../button'
 | 
				
			||||||
 | 
					import { ReplyToggle } from '../comments/comments'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type ReplyTo = { id: string; username: string }
 | 
					export type ReplyTo = { id: string; username: string }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,13 +34,31 @@ export function FeedCommentThread(props: {
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
  const { contract, threadComments, tips, parentComment } = props
 | 
					  const { contract, threadComments, tips, parentComment } = props
 | 
				
			||||||
  const [replyTo, setReplyTo] = useState<ReplyTo>()
 | 
					  const [replyTo, setReplyTo] = useState<ReplyTo>()
 | 
				
			||||||
 | 
					  const [seeReplies, setSeeReplies] = useState(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <Col className="relative w-full items-stretch gap-3 pb-4">
 | 
					    <Col className="relative w-full items-stretch gap-3 pb-4">
 | 
				
			||||||
      {[parentComment].concat(threadComments).map((comment, commentIdx) => (
 | 
					      <Col>
 | 
				
			||||||
 | 
					        <ParentFeedComment
 | 
				
			||||||
 | 
					          key={parentComment.id}
 | 
				
			||||||
 | 
					          contract={contract}
 | 
				
			||||||
 | 
					          comment={parentComment}
 | 
				
			||||||
 | 
					          tips={tips[parentComment.id] ?? {}}
 | 
				
			||||||
 | 
					          seeReplies={seeReplies}
 | 
				
			||||||
 | 
					          numComments={threadComments.length}
 | 
				
			||||||
 | 
					          onSeeReplyClick={() => setSeeReplies(!seeReplies)}
 | 
				
			||||||
 | 
					          onReplyClick={() =>
 | 
				
			||||||
 | 
					            setReplyTo({
 | 
				
			||||||
 | 
					              id: parentComment.id,
 | 
				
			||||||
 | 
					              username: parentComment.userUsername,
 | 
				
			||||||
 | 
					            })
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
 | 
					        />
 | 
				
			||||||
 | 
					      </Col>
 | 
				
			||||||
 | 
					      {seeReplies &&
 | 
				
			||||||
 | 
					        threadComments.map((comment, commentIdx) => (
 | 
				
			||||||
          <FeedComment
 | 
					          <FeedComment
 | 
				
			||||||
            key={comment.id}
 | 
					            key={comment.id}
 | 
				
			||||||
          indent={commentIdx != 0}
 | 
					 | 
				
			||||||
            contract={contract}
 | 
					            contract={contract}
 | 
				
			||||||
            comment={comment}
 | 
					            comment={comment}
 | 
				
			||||||
            tips={tips[comment.id] ?? {}}
 | 
					            tips={tips[comment.id] ?? {}}
 | 
				
			||||||
| 
						 | 
					@ -65,15 +84,24 @@ export function FeedCommentThread(props: {
 | 
				
			||||||
    </Col>
 | 
					    </Col>
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					export function ParentFeedComment(props: {
 | 
				
			||||||
export function FeedComment(props: {
 | 
					 | 
				
			||||||
  contract: Contract
 | 
					  contract: Contract
 | 
				
			||||||
  comment: ContractComment
 | 
					  comment: ContractComment
 | 
				
			||||||
  tips?: CommentTips
 | 
					  tips?: CommentTips
 | 
				
			||||||
  indent?: boolean
 | 
					  seeReplies: boolean
 | 
				
			||||||
 | 
					  numComments: number
 | 
				
			||||||
  onReplyClick?: () => void
 | 
					  onReplyClick?: () => void
 | 
				
			||||||
 | 
					  onSeeReplyClick: () => void
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
  const { contract, comment, tips, indent, onReplyClick } = props
 | 
					  const {
 | 
				
			||||||
 | 
					    contract,
 | 
				
			||||||
 | 
					    comment,
 | 
				
			||||||
 | 
					    tips,
 | 
				
			||||||
 | 
					    onReplyClick,
 | 
				
			||||||
 | 
					    onSeeReplyClick,
 | 
				
			||||||
 | 
					    seeReplies,
 | 
				
			||||||
 | 
					    numComments,
 | 
				
			||||||
 | 
					  } = props
 | 
				
			||||||
  const { text, content, userUsername, userAvatarUrl } = comment
 | 
					  const { text, content, userUsername, userAvatarUrl } = comment
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const router = useRouter()
 | 
					  const router = useRouter()
 | 
				
			||||||
| 
						 | 
					@ -93,25 +121,14 @@ export function FeedComment(props: {
 | 
				
			||||||
      ref={commentRef}
 | 
					      ref={commentRef}
 | 
				
			||||||
      id={comment.id}
 | 
					      id={comment.id}
 | 
				
			||||||
      className={clsx(
 | 
					      className={clsx(
 | 
				
			||||||
        'hover:bg-greyscale-1 gap-2 transition-colors',
 | 
					        'hover:bg-greyscale-1 ml-3 gap-2 transition-colors',
 | 
				
			||||||
        indent ? 'ml-8' : '',
 | 
					 | 
				
			||||||
        highlighted ? `-m-1.5 rounded bg-indigo-500/[0.2] p-1.5` : ''
 | 
					        highlighted ? `-m-1.5 rounded bg-indigo-500/[0.2] p-1.5` : ''
 | 
				
			||||||
      )}
 | 
					      )}
 | 
				
			||||||
      onMouseOver={() => setShowActions(true)}
 | 
					      onMouseOver={() => setShowActions(true)}
 | 
				
			||||||
      onMouseLeave={() => setShowActions(false)}
 | 
					      onMouseLeave={() => setShowActions(false)}
 | 
				
			||||||
    >
 | 
					    >
 | 
				
			||||||
      <Col className={clsx(indent ? '-ml-3' : '')}>
 | 
					      <Col className="-ml-3.5">
 | 
				
			||||||
        <Avatar
 | 
					        <Avatar size="sm" username={userUsername} avatarUrl={userAvatarUrl} />
 | 
				
			||||||
          size={indent ? 'xs' : 'sm'}
 | 
					 | 
				
			||||||
          username={userUsername}
 | 
					 | 
				
			||||||
          avatarUrl={userAvatarUrl}
 | 
					 | 
				
			||||||
        />
 | 
					 | 
				
			||||||
        {indent && (
 | 
					 | 
				
			||||||
          <span
 | 
					 | 
				
			||||||
            className="bg-greyscale-2 mx-auto h-full w-0.5"
 | 
					 | 
				
			||||||
            aria-hidden="true"
 | 
					 | 
				
			||||||
          />
 | 
					 | 
				
			||||||
        )}
 | 
					 | 
				
			||||||
      </Col>
 | 
					      </Col>
 | 
				
			||||||
      <Col className="w-full">
 | 
					      <Col className="w-full">
 | 
				
			||||||
        <FeedCommentHeader comment={comment} contract={contract} />
 | 
					        <FeedCommentHeader comment={comment} contract={contract} />
 | 
				
			||||||
| 
						 | 
					@ -121,6 +138,13 @@ export function FeedComment(props: {
 | 
				
			||||||
          content={content || text}
 | 
					          content={content || text}
 | 
				
			||||||
          smallImage
 | 
					          smallImage
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
 | 
					        <Row className="justify-between">
 | 
				
			||||||
 | 
					          <ReplyToggle
 | 
				
			||||||
 | 
					            seeReplies={seeReplies}
 | 
				
			||||||
 | 
					            numComments={numComments}
 | 
				
			||||||
 | 
					            onClick={onSeeReplyClick}
 | 
				
			||||||
 | 
					          />
 | 
				
			||||||
 | 
					          <Row className="grow justify-end">
 | 
				
			||||||
            <CommentActions
 | 
					            <CommentActions
 | 
				
			||||||
              showActions={showActions}
 | 
					              showActions={showActions}
 | 
				
			||||||
              onReplyClick={onReplyClick}
 | 
					              onReplyClick={onReplyClick}
 | 
				
			||||||
| 
						 | 
					@ -128,6 +152,69 @@ export function FeedComment(props: {
 | 
				
			||||||
              comment={comment}
 | 
					              comment={comment}
 | 
				
			||||||
              contract={contract}
 | 
					              contract={contract}
 | 
				
			||||||
            />
 | 
					            />
 | 
				
			||||||
 | 
					          </Row>
 | 
				
			||||||
 | 
					        </Row>
 | 
				
			||||||
 | 
					      </Col>
 | 
				
			||||||
 | 
					    </Row>
 | 
				
			||||||
 | 
					  )
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export function FeedComment(props: {
 | 
				
			||||||
 | 
					  contract: Contract
 | 
				
			||||||
 | 
					  comment: ContractComment
 | 
				
			||||||
 | 
					  tips?: CommentTips
 | 
				
			||||||
 | 
					  onReplyClick?: () => void
 | 
				
			||||||
 | 
					}) {
 | 
				
			||||||
 | 
					  const { contract, comment, tips, onReplyClick } = props
 | 
				
			||||||
 | 
					  const { text, content, userUsername, userAvatarUrl } = comment
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const router = useRouter()
 | 
				
			||||||
 | 
					  const highlighted = router.asPath.endsWith(`#${comment.id}`)
 | 
				
			||||||
 | 
					  const commentRef = useRef<HTMLDivElement>(null)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  useEffect(() => {
 | 
				
			||||||
 | 
					    if (highlighted && commentRef.current != null) {
 | 
				
			||||||
 | 
					      commentRef.current.scrollIntoView(true)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }, [highlighted])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const [showActions, setShowActions] = useState(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return (
 | 
				
			||||||
 | 
					    <Row
 | 
				
			||||||
 | 
					      ref={commentRef}
 | 
				
			||||||
 | 
					      id={comment.id}
 | 
				
			||||||
 | 
					      className={clsx(
 | 
				
			||||||
 | 
					        'hover:bg-greyscale-1 ml-8 gap-2 transition-colors',
 | 
				
			||||||
 | 
					        highlighted ? `-m-1.5 rounded bg-indigo-500/[0.2] p-1.5` : ''
 | 
				
			||||||
 | 
					      )}
 | 
				
			||||||
 | 
					      onMouseOver={() => setShowActions(true)}
 | 
				
			||||||
 | 
					      onMouseLeave={() => setShowActions(false)}
 | 
				
			||||||
 | 
					    >
 | 
				
			||||||
 | 
					      <Col className="-ml-3">
 | 
				
			||||||
 | 
					        <Avatar size="xs" username={userUsername} avatarUrl={userAvatarUrl} />
 | 
				
			||||||
 | 
					        <span
 | 
				
			||||||
 | 
					          className="bg-greyscale-4 mx-auto h-full w-[1.5px]"
 | 
				
			||||||
 | 
					          aria-hidden="true"
 | 
				
			||||||
 | 
					        />
 | 
				
			||||||
 | 
					      </Col>
 | 
				
			||||||
 | 
					      <Col className="w-full">
 | 
				
			||||||
 | 
					        <FeedCommentHeader comment={comment} contract={contract} />
 | 
				
			||||||
 | 
					        {/* TODO: bug where if this is iFrame, it does not scroll */}
 | 
				
			||||||
 | 
					        <Content
 | 
				
			||||||
 | 
					          className="text-greyscale-7 mt-2 grow text-[14px]"
 | 
				
			||||||
 | 
					          content={content || text}
 | 
				
			||||||
 | 
					          smallImage
 | 
				
			||||||
 | 
					        />
 | 
				
			||||||
 | 
					        <Row className="justify-end">
 | 
				
			||||||
 | 
					          <CommentActions
 | 
				
			||||||
 | 
					            showActions={showActions}
 | 
				
			||||||
 | 
					            onReplyClick={onReplyClick}
 | 
				
			||||||
 | 
					            tips={tips}
 | 
				
			||||||
 | 
					            comment={comment}
 | 
				
			||||||
 | 
					            contract={contract}
 | 
				
			||||||
 | 
					          />
 | 
				
			||||||
 | 
					        </Row>
 | 
				
			||||||
      </Col>
 | 
					      </Col>
 | 
				
			||||||
    </Row>
 | 
					    </Row>
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
| 
						 | 
					@ -144,7 +231,7 @@ export function CommentActions(props: {
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <Row
 | 
					    <Row
 | 
				
			||||||
      className={clsx(
 | 
					      className={clsx(
 | 
				
			||||||
        'ml-2 items-center justify-end gap-2 text-xs text-gray-500 transition-opacity',
 | 
					        'ml-2 items-center gap-2 text-xs text-gray-500 transition-opacity',
 | 
				
			||||||
        showActions ? '' : 'md:opacity-0'
 | 
					        showActions ? '' : 'md:opacity-0'
 | 
				
			||||||
      )}
 | 
					      )}
 | 
				
			||||||
    >
 | 
					    >
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user