e567782a7d
* Add tip arrows UI (visual) * move tipper into its own component * simplify score calculation * Add tip txns - more specific txn types - fix transact cloud function to be able to create tip txns - insert tips into comments via a context * Refactor tipper to send tip txns * Stop tipping yourself. Disable anons. * Style tipper (smaller) * remove default exports * capitalize tooltips * rename stuff * add exhausting hook dependencies * replace context with prop threading * fix eslint unused vars
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
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'
|
|
import { getSpecificContractActivityItems } from './activity-items'
|
|
import { FeedItems } from './feed-items'
|
|
import { User } from 'common/user'
|
|
import { useContractWithPreload } from 'web/hooks/use-contract'
|
|
import { CommentTipMap } from 'web/hooks/use-tip-txns'
|
|
|
|
export function ContractActivity(props: {
|
|
contract: Contract
|
|
bets: Bet[]
|
|
comments: Comment[]
|
|
tips: CommentTipMap
|
|
user: User | null | undefined
|
|
mode: 'comments' | 'bets' | 'free-response-comment-answer-groups'
|
|
contractPath?: string
|
|
className?: string
|
|
betRowClassName?: string
|
|
}) {
|
|
const { user, mode, tips, className, betRowClassName } = props
|
|
|
|
const contract = useContractWithPreload(props.contract) ?? props.contract
|
|
|
|
const updatedComments = useComments(contract.id)
|
|
const comments = updatedComments ?? props.comments
|
|
|
|
const updatedBets = useBets(contract.id)
|
|
const bets = (updatedBets ?? props.bets).filter((bet) => !bet.isRedemption)
|
|
const items = getSpecificContractActivityItems(
|
|
contract,
|
|
bets,
|
|
comments,
|
|
tips,
|
|
user,
|
|
{ mode }
|
|
)
|
|
|
|
return (
|
|
<FeedItems
|
|
contract={contract}
|
|
items={items}
|
|
className={className}
|
|
betRowClassName={betRowClassName}
|
|
/>
|
|
)
|
|
}
|