Remove filterToOutcome
This commit is contained in:
parent
9c74f88b4a
commit
88b8d39c7c
|
@ -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,18 +268,7 @@ 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
|
||||
const items: ActivityItem[] = abbreviated
|
||||
? [
|
||||
{
|
||||
type: 'question',
|
||||
|
@ -298,7 +280,7 @@ export function getAllContractActivityItems(
|
|||
: [{ 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,
|
||||
}))
|
||||
)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user