diff --git a/web/components/contract/prob-change-table.tsx b/web/components/contract/prob-change-table.tsx index f54ad915..6b671830 100644 --- a/web/components/contract/prob-change-table.tsx +++ b/web/components/contract/prob-change-table.tsx @@ -1,5 +1,5 @@ +import { sortBy } from 'lodash' import clsx from 'clsx' -import { partition } from 'lodash' import { contractPath } from 'web/lib/firebase/contracts' import { CPMMContract } from 'common/contract' import { formatPercent } from 'common/util/format' @@ -17,16 +17,14 @@ export function ProbChangeTable(props: { if (!changes) return - const [positiveChanges, negativeChanges] = partition( - changes, - (c) => c.probChanges.day > 0 - ) + const descendingChanges = sortBy(changes, (c) => c.probChanges.day).reverse() + const ascendingChanges = sortBy(changes, (c) => c.probChanges.day) const threshold = 0.01 - const positiveAboveThreshold = positiveChanges.filter( + const positiveAboveThreshold = descendingChanges.filter( (c) => c.probChanges.day > threshold ) - const negativeAboveThreshold = negativeChanges.filter( + const negativeAboveThreshold = ascendingChanges.filter( (c) => c.probChanges.day < threshold ) const maxRows = Math.min( diff --git a/web/pages/daily-movers.tsx b/web/pages/daily-movers.tsx index 0a17e9e2..53e37420 100644 --- a/web/pages/daily-movers.tsx +++ b/web/pages/daily-movers.tsx @@ -8,20 +8,24 @@ import { useUser } from 'web/hooks/use-user' export default function DailyMovers() { const user = useUser() - const bettorId = user?.id ?? undefined - - const changes = useProbChanges({ bettorId })?.filter( - (c) => Math.abs(c.probChanges.day) >= 0.01 - ) - useTracking('view daily movers') return ( - <ProbChangeTable changes={changes} full /> + {user && <ProbChangesWrapper userId={user.id} />} </Col> </Page> ) } + +function ProbChangesWrapper(props: { userId: string }) { + const { userId } = props + + const changes = useProbChanges({ bettorId: userId })?.filter( + (c) => Math.abs(c.probChanges.day) >= 0.01 + ) + + return <ProbChangeTable changes={changes} full /> +} diff --git a/web/pages/home/index.tsx b/web/pages/home/index.tsx index ba2851bf..e920b20f 100644 --- a/web/pages/home/index.tsx +++ b/web/pages/home/index.tsx @@ -286,9 +286,9 @@ function GroupSection(props: { ) } -function DailyMoversSection(props: { userId: string | null | undefined }) { +function DailyMoversSection(props: { userId: string }) { const { userId } = props - const changes = useProbChanges({ bettorId: userId ?? undefined })?.filter( + const changes = useProbChanges({ bettorId: userId })?.filter( (c) => Math.abs(c.probChanges.day) >= 0.01 )