Load daily movers at top level as well
This commit is contained in:
parent
a7f6cb7cfa
commit
10e361bcac
|
@ -74,6 +74,7 @@ export default function Home() {
|
||||||
}
|
}
|
||||||
}, [user, sections])
|
}, [user, sections])
|
||||||
|
|
||||||
|
const dailyMovers = useProbChanges({ bettorId: user?.id })
|
||||||
const trendingContracts = useTrendingContracts(6)
|
const trendingContracts = useTrendingContracts(6)
|
||||||
const newContracts = useNewContracts(6)
|
const newContracts = useNewContracts(6)
|
||||||
const dailyTrendingContracts = useContractsByDailyScoreNotBetOn(user?.id, 6)
|
const dailyTrendingContracts = useContractsByDailyScoreNotBetOn(user?.id, 6)
|
||||||
|
@ -84,7 +85,11 @@ export default function Home() {
|
||||||
)
|
)
|
||||||
|
|
||||||
const isLoading =
|
const isLoading =
|
||||||
!user || !trendingContracts || !newContracts || !dailyTrendingContracts
|
!user ||
|
||||||
|
!dailyMovers ||
|
||||||
|
!trendingContracts ||
|
||||||
|
!newContracts ||
|
||||||
|
!dailyTrendingContracts
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
|
@ -110,6 +115,7 @@ export default function Home() {
|
||||||
score: trendingContracts,
|
score: trendingContracts,
|
||||||
newest: newContracts,
|
newest: newContracts,
|
||||||
'daily-trending': dailyTrendingContracts,
|
'daily-trending': dailyTrendingContracts,
|
||||||
|
'daily-movers': dailyMovers,
|
||||||
})}
|
})}
|
||||||
|
|
||||||
<TrendingGroupsSection user={user} />
|
<TrendingGroupsSection user={user} />
|
||||||
|
@ -166,6 +172,7 @@ function renderSections(
|
||||||
user: User,
|
user: User,
|
||||||
sections: { id: string; label: string }[],
|
sections: { id: string; label: string }[],
|
||||||
sectionContracts: {
|
sectionContracts: {
|
||||||
|
'daily-movers': CPMMBinaryContract[]
|
||||||
'daily-trending': CPMMBinaryContract[]
|
'daily-trending': CPMMBinaryContract[]
|
||||||
newest: CPMMBinaryContract[]
|
newest: CPMMBinaryContract[]
|
||||||
score: CPMMBinaryContract[]
|
score: CPMMBinaryContract[]
|
||||||
|
@ -175,22 +182,23 @@ function renderSections(
|
||||||
<>
|
<>
|
||||||
{sections.map((s) => {
|
{sections.map((s) => {
|
||||||
const { id, label } = s
|
const { id, label } = s
|
||||||
|
const contracts =
|
||||||
|
sectionContracts[s.id as keyof typeof sectionContracts]
|
||||||
|
|
||||||
if (id === 'daily-movers') {
|
if (id === 'daily-movers') {
|
||||||
return <DailyMoversSection key={id} userId={user.id} />
|
return <DailyMoversSection key={id} contracts={contracts} />
|
||||||
}
|
}
|
||||||
if (id === 'daily-trending') {
|
if (id === 'daily-trending') {
|
||||||
return (
|
return (
|
||||||
<ContractsSection
|
<ContractsSection
|
||||||
key={id}
|
key={id}
|
||||||
label={label}
|
label={label}
|
||||||
contracts={sectionContracts[id]}
|
contracts={contracts}
|
||||||
sort="daily-score"
|
sort="daily-score"
|
||||||
showProbChange
|
showProbChange
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const contracts =
|
|
||||||
sectionContracts[s.id as keyof typeof sectionContracts]
|
|
||||||
return (
|
return (
|
||||||
<ContractsSection
|
<ContractsSection
|
||||||
key={id}
|
key={id}
|
||||||
|
@ -325,13 +333,12 @@ function GroupSection(props: {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function DailyMoversSection(props: { userId: string }) {
|
function DailyMoversSection(props: { contracts: CPMMBinaryContract[] }) {
|
||||||
const { userId } = props
|
const { contracts } = props
|
||||||
const changes = useProbChanges({ bettorId: userId })?.filter(
|
|
||||||
(c) => Math.abs(c.probChanges.day) >= 0.01
|
|
||||||
)
|
|
||||||
|
|
||||||
if (changes && changes.length === 0) {
|
const changes = contracts.filter((c) => Math.abs(c.probChanges.day) >= 0.01)
|
||||||
|
|
||||||
|
if (changes.length === 0) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user