Don't show resolved markets in hot markets

This commit is contained in:
jahooma 2022-01-09 12:14:20 -06:00
parent 34b208f63d
commit 6d4554e9ef
3 changed files with 12 additions and 8 deletions

View File

@ -146,7 +146,7 @@ export function computeHotContracts(recentBets: Bet[]) {
const contractBets = _.groupBy(recentBets, (bet) => bet.contractId) const contractBets = _.groupBy(recentBets, (bet) => bet.contractId)
const hotContractIds = _.sortBy(Object.keys(contractBets), (contractId) => const hotContractIds = _.sortBy(Object.keys(contractBets), (contractId) =>
_.sumBy(contractBets[contractId], (bet) => -1 * bet.amount) _.sumBy(contractBets[contractId], (bet) => -1 * bet.amount)
).slice(0, 4) )
return hotContractIds return hotContractIds
} }

View File

@ -32,9 +32,10 @@ const Home = (props: { contracts: Contract[]; hotContractIds: string[] }) => {
if (user === undefined) return <></> if (user === undefined) return <></>
const { contracts, hotContractIds } = props const { contracts, hotContractIds } = props
const hotContracts = hotContractIds.map( const hotContracts = hotContractIds
(id) => contracts.find((contract) => contract.id === id) as Contract .map((id) => contracts.find((contract) => contract.id === id) as Contract)
) .filter((contract) => !contract.isResolved)
.slice(0, 4)
return user ? ( return user ? (
<Markets contracts={contracts} hotContractIds={hotContractIds} /> <Markets contracts={contracts} hotContractIds={hotContractIds} />

View File

@ -39,10 +39,13 @@ export default function Markets(props: {
hotContractIds === 'loading' ? props.hotContractIds : hotContractIds hotContractIds === 'loading' ? props.hotContractIds : hotContractIds
const readyContracts = contracts === 'loading' ? props.contracts : contracts const readyContracts = contracts === 'loading' ? props.contracts : contracts
const hotContracts = readyHotContractIds.map( const hotContracts = readyHotContractIds
.map(
(hotId) => (hotId) =>
_.find(readyContracts, (contract) => contract.id === hotId) as Contract _.find(readyContracts, (contract) => contract.id === hotId) as Contract
) )
.filter((contract) => !contract.isResolved)
.slice(0, 4)
return ( return (
<Page> <Page>