From 10e361bcac314e17c1b0c0685da7b054a37900ef Mon Sep 17 00:00:00 2001 From: James Grugett Date: Sun, 2 Oct 2022 14:59:02 -0500 Subject: [PATCH] Load daily movers at top level as well --- web/pages/home/index.tsx | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/web/pages/home/index.tsx b/web/pages/home/index.tsx index f4cd73bc..fdfa620d 100644 --- a/web/pages/home/index.tsx +++ b/web/pages/home/index.tsx @@ -74,6 +74,7 @@ export default function Home() { } }, [user, sections]) + const dailyMovers = useProbChanges({ bettorId: user?.id }) const trendingContracts = useTrendingContracts(6) const newContracts = useNewContracts(6) const dailyTrendingContracts = useContractsByDailyScoreNotBetOn(user?.id, 6) @@ -84,7 +85,11 @@ export default function Home() { ) const isLoading = - !user || !trendingContracts || !newContracts || !dailyTrendingContracts + !user || + !dailyMovers || + !trendingContracts || + !newContracts || + !dailyTrendingContracts return ( @@ -110,6 +115,7 @@ export default function Home() { score: trendingContracts, newest: newContracts, 'daily-trending': dailyTrendingContracts, + 'daily-movers': dailyMovers, })} @@ -166,6 +172,7 @@ function renderSections( user: User, sections: { id: string; label: string }[], sectionContracts: { + 'daily-movers': CPMMBinaryContract[] 'daily-trending': CPMMBinaryContract[] newest: CPMMBinaryContract[] score: CPMMBinaryContract[] @@ -175,22 +182,23 @@ function renderSections( <> {sections.map((s) => { const { id, label } = s + const contracts = + sectionContracts[s.id as keyof typeof sectionContracts] + if (id === 'daily-movers') { - return + return } if (id === 'daily-trending') { return ( ) } - const contracts = - sectionContracts[s.id as keyof typeof sectionContracts] return ( Math.abs(c.probChanges.day) >= 0.01 - ) +function DailyMoversSection(props: { contracts: CPMMBinaryContract[] }) { + const { contracts } = props - if (changes && changes.length === 0) { + const changes = contracts.filter((c) => Math.abs(c.probChanges.day) >= 0.01) + + if (changes.length === 0) { return null }