2022-05-09 13:04:36 +00:00
|
|
|
import { Contract } from 'web/lib/firebase/contracts'
|
|
|
|
import { Comment } from 'web/lib/firebase/comments'
|
|
|
|
import { Bet } from 'common/bet'
|
|
|
|
import { useBets } from 'web/hooks/use-bets'
|
|
|
|
import { useComments } from 'web/hooks/use-comments'
|
2022-06-14 13:13:24 +00:00
|
|
|
import { getSpecificContractActivityItems } from './activity-items'
|
2022-03-14 20:29:32 +00:00
|
|
|
import { FeedItems } from './feed-items'
|
2022-05-09 13:04:36 +00:00
|
|
|
import { User } from 'common/user'
|
2022-06-10 23:36:18 +00:00
|
|
|
import { useContractWithPreload } from 'web/hooks/use-contract'
|
2022-06-18 03:28:16 +00:00
|
|
|
import { CommentTipMap } from 'web/hooks/use-tip-txns'
|
2022-03-14 20:29:32 +00:00
|
|
|
|
|
|
|
export function ContractActivity(props: {
|
|
|
|
contract: Contract
|
|
|
|
bets: Bet[]
|
|
|
|
comments: Comment[]
|
2022-06-18 03:28:16 +00:00
|
|
|
tips: CommentTipMap
|
2022-03-14 20:29:32 +00:00
|
|
|
user: User | null | undefined
|
2022-06-14 13:13:24 +00:00
|
|
|
mode: 'comments' | 'bets' | 'free-response-comment-answer-groups'
|
2022-04-11 21:13:26 +00:00
|
|
|
contractPath?: string
|
2022-04-06 05:22:43 +00:00
|
|
|
className?: string
|
2022-03-14 20:29:32 +00:00
|
|
|
betRowClassName?: string
|
|
|
|
}) {
|
2022-06-18 03:28:16 +00:00
|
|
|
const { user, mode, tips, className, betRowClassName } = props
|
2022-05-12 15:07:10 +00:00
|
|
|
|
2022-06-10 23:36:18 +00:00
|
|
|
const contract = useContractWithPreload(props.contract) ?? props.contract
|
2022-03-14 20:29:32 +00:00
|
|
|
|
2022-06-14 13:13:24 +00:00
|
|
|
const updatedComments = useComments(contract.id)
|
2022-03-14 20:29:32 +00:00
|
|
|
const comments = updatedComments ?? props.comments
|
|
|
|
|
2022-06-14 13:13:24 +00:00
|
|
|
const updatedBets = useBets(contract.id)
|
2022-05-28 20:57:12 +00:00
|
|
|
const bets = (updatedBets ?? props.bets).filter((bet) => !bet.isRedemption)
|
2022-06-14 13:13:24 +00:00
|
|
|
const items = getSpecificContractActivityItems(
|
|
|
|
contract,
|
|
|
|
bets,
|
|
|
|
comments,
|
2022-06-18 03:28:16 +00:00
|
|
|
tips,
|
2022-06-14 13:13:24 +00:00
|
|
|
user,
|
|
|
|
{ mode }
|
|
|
|
)
|
2022-03-14 20:29:32 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<FeedItems
|
|
|
|
contract={contract}
|
|
|
|
items={items}
|
2022-04-06 05:22:43 +00:00
|
|
|
className={className}
|
2022-03-14 20:29:32 +00:00
|
|
|
betRowClassName={betRowClassName}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|