Remove filterToOutcome

This commit is contained in:
James Grugett 2022-04-18 20:54:31 -05:00
parent 9c74f88b4a
commit 88b8d39c7c
3 changed files with 18 additions and 79 deletions

View File

@ -18,7 +18,6 @@ export type ActivityItem =
| QuestionItem | QuestionItem
| BetItem | BetItem
| CommentItem | CommentItem
| CreateAnswerItem
| BetGroupItem | BetGroupItem
| AnswerGroupItem | AnswerGroupItem
| CloseItem | CloseItem
@ -55,11 +54,6 @@ export type CommentItem = BaseActivityItem & {
smallAvatar: boolean smallAvatar: boolean
} }
export type CreateAnswerItem = BaseActivityItem & {
type: 'createanswer'
answer: Answer
}
export type BetGroupItem = BaseActivityItem & { export type BetGroupItem = BaseActivityItem & {
type: 'betgroup' type: 'betgroup'
bets: Bet[] bets: Bet[]
@ -260,7 +254,6 @@ export function getAllContractActivityItems(
bets: Bet[], bets: Bet[],
comments: Comment[], comments: Comment[],
user: User | null | undefined, user: User | null | undefined,
filterToOutcome: string | undefined,
options: { options: {
abbreviated: boolean abbreviated: boolean
} }
@ -275,18 +268,7 @@ export function getAllContractActivityItems(
? bets.filter((bet) => !bet.isAnte && !bet.isRedemption) ? bets.filter((bet) => !bet.isAnte && !bet.isRedemption)
: bets.filter((bet) => !(bet.isAnte && (bet.outcome as string) === '0')) : bets.filter((bet) => !(bet.isAnte && (bet.outcome as string) === '0'))
let answer: Answer | undefined const items: ActivityItem[] = abbreviated
if (filterToOutcome) {
bets = bets.filter((bet) => bet.outcome === filterToOutcome)
answer = (contract as FullContract<DPM, FreeResponse>).answers?.find(
(answer) => answer.id === filterToOutcome
)
}
const items: ActivityItem[] =
filterToOutcome && answer
? [{ type: 'createanswer', id: answer.id, contract, answer }]
: abbreviated
? [ ? [
{ {
type: 'question', type: 'question',
@ -298,7 +280,7 @@ export function getAllContractActivityItems(
: [{ type: 'description', id: '0', contract }] : [{ type: 'description', id: '0', contract }]
items.push( items.push(
...(outcomeType === 'FREE_RESPONSE' && !filterToOutcome ...(outcomeType === 'FREE_RESPONSE'
? getAnswerGroups( ? getAnswerGroups(
contract as FullContract<DPM, FreeResponse>, contract as FullContract<DPM, FreeResponse>,
bets, bets,
@ -311,9 +293,9 @@ export function getAllContractActivityItems(
} }
) )
: groupBets(bets, comments, contract, user?.id, { : groupBets(bets, comments, contract, user?.id, {
hideOutcome: !!filterToOutcome, hideOutcome: false,
abbreviated, abbreviated,
smallAvatar: !!filterToOutcome, smallAvatar: false,
reversed: false, reversed: false,
})) }))
) )

View File

@ -18,20 +18,12 @@ export function ContractActivity(props: {
comments: Comment[] comments: Comment[]
user: User | null | undefined user: User | null | undefined
mode: 'only-recent' | 'abbreviated' | 'all' mode: 'only-recent' | 'abbreviated' | 'all'
filterToOutcome?: string // Which multi-category outcome to filter
contractPath?: string contractPath?: string
className?: string className?: string
betRowClassName?: string betRowClassName?: string
}) { }) {
const { const { contract, user, mode, contractPath, className, betRowClassName } =
contract, props
user,
filterToOutcome,
mode,
contractPath,
className,
betRowClassName,
} = props
const updatedComments = const updatedComments =
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
@ -47,14 +39,9 @@ export function ContractActivity(props: {
? getRecentContractActivityItems(contract, bets, comments, user, { ? getRecentContractActivityItems(contract, bets, comments, user, {
contractPath, contractPath,
}) })
: getAllContractActivityItems( : getAllContractActivityItems(contract, bets, comments, user, {
contract, abbreviated: mode === 'abbreviated',
bets, })
comments,
user,
filterToOutcome,
{ abbreviated: mode === 'abbreviated' }
)
return ( return (
<FeedItems <FeedItems

View File

@ -96,8 +96,6 @@ function FeedItem(props: { item: ActivityItem }) {
return <FeedComment {...item} /> return <FeedComment {...item} />
case 'bet': case 'bet':
return <FeedBet {...item} /> return <FeedBet {...item} />
case 'createanswer':
return <FeedCreateAnswer {...item} />
case 'betgroup': case 'betgroup':
return <FeedBetGroup {...item} /> return <FeedBetGroup {...item} />
case 'answergroup': case 'answergroup':
@ -399,34 +397,6 @@ function FeedDescription(props: { contract: Contract }) {
) )
} }
function FeedCreateAnswer(props: {
contract: FullContract<any, FreeResponse>
answer: Answer
}) {
const { answer } = props
return (
<>
<Avatar
className="ml-1"
size="sm"
username={answer.username}
avatarUrl={answer.avatarUrl}
/>
<div className="min-w-0 flex-1 py-1.5">
<div className="text-sm text-gray-500">
<UserLink
className="text-gray-900"
name={answer.name}
username={answer.username}
/>{' '}
submitted this answer <RelativeTimestamp time={answer.createdTime} />
</div>
</div>
</>
)
}
function OutcomeIcon(props: { outcome?: string }) { function OutcomeIcon(props: { outcome?: string }) {
const { outcome } = props const { outcome } = props
switch (outcome) { switch (outcome) {