2022-05-09 13:04:36 +00:00
|
|
|
import { Contract } from 'web/lib/firebase/contracts'
|
2022-08-19 08:06:40 +00:00
|
|
|
import { ContractComment } from 'common/comment'
|
2022-05-09 13:04:36 +00:00
|
|
|
import { Bet } from 'common/bet'
|
|
|
|
import { useBets } from 'web/hooks/use-bets'
|
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-06-27 00:00:02 +00:00
|
|
|
import { LiquidityProvision } from 'common/liquidity-provision'
|
2022-03-14 20:29:32 +00:00
|
|
|
|
|
|
|
export function ContractActivity(props: {
|
|
|
|
contract: Contract
|
|
|
|
bets: Bet[]
|
2022-08-19 08:06:40 +00:00
|
|
|
comments: ContractComment[]
|
2022-06-27 00:00:02 +00:00
|
|
|
liquidityProvisions: LiquidityProvision[]
|
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-27 00:00:02 +00:00
|
|
|
const { user, mode, tips, className, betRowClassName, liquidityProvisions } =
|
|
|
|
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-07-24 07:11:33 +00:00
|
|
|
const comments = props.comments
|
2022-08-04 21:27:02 +00:00
|
|
|
const updatedBets = useBets(contract.id, {
|
|
|
|
filterChallenges: false,
|
|
|
|
filterRedemptions: true,
|
|
|
|
})
|
2022-07-10 18:05:44 +00:00
|
|
|
const bets = (updatedBets ?? props.bets).filter(
|
|
|
|
(bet) => !bet.isRedemption && bet.amount !== 0
|
|
|
|
)
|
2022-06-14 13:13:24 +00:00
|
|
|
const items = getSpecificContractActivityItems(
|
|
|
|
contract,
|
|
|
|
bets,
|
|
|
|
comments,
|
2022-06-27 00:00:02 +00:00
|
|
|
liquidityProvisions,
|
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}
|
2022-07-26 00:45:33 +00:00
|
|
|
user={user}
|
2022-03-14 20:29:32 +00:00
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|