// From https://tailwindui.com/components/application-ui/lists/feeds import React, { useState } from 'react' import * as _ from 'lodash' import { BanIcon, CheckIcon, DotsVerticalIcon, LockClosedIcon, XIcon, } from '@heroicons/react/solid' import clsx from 'clsx' import { OutcomeLabel } from '../outcome-label' import { Contract, contractMetrics, contractPath, tradingAllowed, } from 'web/lib/firebase/contracts' import { BinaryResolutionOrChance } from '../contract/contract-card' import { SiteLink } from '../site-link' import { Col } from '../layout/col' import { UserLink } from '../user-page' import BetRow from '../bet-row' import { Avatar } from '../avatar' import { ActivityItem } from './activity-items' import { useSaveSeenContract } from 'web/hooks/use-seen-contracts' import { trackClick } from 'web/lib/firebase/tracking' import { DAY_MS } from 'common/util/time' import NewContractBadge from '../new-contract-badge' import { RelativeTimestamp } from '../relative-timestamp' import { FeedAnswerCommentGroup } from 'web/components/feed/feed-answer-comment-group' import { FeedCommentThread, FeedComment, CommentInput, TruncatedComment, } from 'web/components/feed/feed-comments' import { FeedBet, FeedBetGroup } from 'web/components/feed/feed-bets' export function FeedItems(props: { contract: Contract items: ActivityItem[] className?: string betRowClassName?: string }) { const { contract, items, className, betRowClassName } = props const { outcomeType } = contract const [elem, setElem] = useState(null) useSaveSeenContract(elem, contract) return (
{items.map((item, activityItemIdx) => (
{activityItemIdx !== items.length - 1 || item.type === 'answergroup' ? (
))}
{outcomeType === 'BINARY' && tradingAllowed(contract) && ( )}
) } export function FeedItem(props: { item: ActivityItem }) { const { item } = props switch (item.type) { case 'question': return case 'description': return case 'comment': return case 'bet': return case 'betgroup': return case 'answergroup': return case 'close': return case 'resolve': return case 'commentInput': return case 'commentThread': return } } export function FeedQuestion(props: { contract: Contract showDescription: boolean contractPath?: string }) { const { contract, showDescription } = props const { creatorName, creatorUsername, question, outcomeType, volume, createdTime, } = contract const { volumeLabel } = contractMetrics(contract) const isBinary = outcomeType === 'BINARY' const isNew = createdTime > Date.now() - DAY_MS return ( <>
{' '} asked {/* Currently hidden on mobile; ideally we'd fit this in somewhere. */}
{isNew || volume === 0 ? ( ) : ( {volumeLabel} )}
trackClick(contract.id)} className="text-lg text-indigo-700 sm:text-xl" > {question} {isBinary && ( )} {showDescription && ( )}
) } function FeedDescription(props: { contract: Contract }) { const { contract } = props const { creatorName, creatorUsername } = contract return ( <>
{' '} created this market
) } function OutcomeIcon(props: { outcome?: string }) { const { outcome } = props switch (outcome) { case 'YES': return