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

View File

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

View File

@ -96,8 +96,6 @@ function FeedItem(props: { item: ActivityItem }) {
return <FeedComment {...item} />
case 'bet':
return <FeedBet {...item} />
case 'createanswer':
return <FeedCreateAnswer {...item} />
case 'betgroup':
return <FeedBetGroup {...item} />
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 }) {
const { outcome } = props
switch (outcome) {