93287f8dc1
* Compute answer group feed items * Refactor feed code into 5 files under feed directory. * Convert to typed ActivityItems * Use feed "mode". Clean up cases. * Implement feed answer groups! * FR: Use nested comments/bets under answers for contract page. filter more items out of FR feed. * Linkify answer text on activity feed * Default feed excluded tags are case insensitive * Show followed folds first * Allow filtering your trades * Store users's last sort in localstorage * Use avatar of user that submitted answer and name instead of pencil icon. Spacing. Show up to 3 comments in asnwer group. * Don't reveal market creator's bets * Fix communites feed to be abbreviated * Remove complicated answer group logic Co-authored-by: Austin Chen <akrolsmir@gmail.com>
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import _ from 'lodash'
|
|
|
|
import { Contract } from '../../lib/firebase/contracts'
|
|
import { Comment } from '../../lib/firebase/comments'
|
|
import { Bet } from '../../../common/bet'
|
|
import { useBets } from '../../hooks/use-bets'
|
|
import { useComments } from '../../hooks/use-comments'
|
|
import {
|
|
getAllContractActivityItems,
|
|
getRecentContractActivityItems,
|
|
} from './activity-items'
|
|
import { FeedItems } from './feed-items'
|
|
import { User } from '../../../common/user'
|
|
|
|
export function ContractActivity(props: {
|
|
contract: Contract
|
|
bets: Bet[]
|
|
comments: Comment[]
|
|
user: User | null | undefined
|
|
mode: 'only-recent' | 'abbreviated' | 'all'
|
|
filterToOutcome?: string // Which multi-category outcome to filter
|
|
betRowClassName?: string
|
|
}) {
|
|
const { contract, user, filterToOutcome, mode, betRowClassName } = props
|
|
|
|
const updatedComments =
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
mode === 'only-recent' ? undefined : useComments(contract.id)
|
|
const comments = updatedComments ?? props.comments
|
|
|
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
const updatedBets = mode === 'only-recent' ? undefined : useBets(contract.id)
|
|
const bets = updatedBets ?? props.bets
|
|
|
|
const items =
|
|
mode === 'only-recent'
|
|
? getRecentContractActivityItems(contract, bets, comments, user)
|
|
: getAllContractActivityItems(
|
|
contract,
|
|
bets,
|
|
comments,
|
|
user,
|
|
filterToOutcome,
|
|
{ abbreviated: mode === 'abbreviated' }
|
|
)
|
|
|
|
return (
|
|
<FeedItems
|
|
contract={contract}
|
|
items={items}
|
|
betRowClassName={betRowClassName}
|
|
/>
|
|
)
|
|
}
|