From 0a98ffe05cd54bc1bec7bd0074840bac7435ffb9 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Fri, 25 Feb 2022 16:57:28 -0800 Subject: [PATCH] Remove sold bets from Your Trades --- web/components/bets-list.tsx | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index b23f1fa2..c9822688 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -37,7 +37,7 @@ import { filterDefined } from '../../common/util/array' import { LoadingIndicator } from './loading-indicator' import { SiteLink } from './site-link' -type BetSort = 'newest' | 'profit' | 'resolved' | 'value' +type BetSort = 'newest' | 'profit' | 'settled' | 'value' export function BetsList(props: { user: User }) { const { user } = props @@ -106,23 +106,20 @@ export function BetsList(props: { user: User }) { contracts, (c) => -1 * Math.max(...contractBets[c.id].map((bet) => bet.createdTime)) ) - else if (sort === 'resolved') + else if (sort === 'settled') sortedContracts = _.sortBy(contracts, (c) => -1 * (c.resolutionTime ?? 0)) - const [resolved, unresolved] = _.partition( + const [settled, unsettled] = _.partition( sortedContracts, - (c) => c.isResolved + (c) => c.isResolved || contractsInvestment[c.id] === 0 ) - const displayedContracts = sort === 'resolved' ? resolved : unresolved + const displayedContracts = sort === 'settled' ? settled : unsettled - const currentInvestment = _.sumBy( - unresolved, - (c) => contractsInvestment[c.id] - ) + const currentInvestment = _.sumBy(unsettled, (c) => contractsInvestment[c.id]) const currentBetsValue = _.sumBy( - unresolved, + unsettled, (c) => contractsCurrentValue[c.id] ) @@ -161,7 +158,7 @@ export function BetsList(props: { user: User }) { - + @@ -228,7 +225,7 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) { /> - + {isBinary && ( <> {resolution ? (