From 6d4554e9efd85344eb1083b865731b6357fe6e8e Mon Sep 17 00:00:00 2001 From: jahooma Date: Sun, 9 Jan 2022 12:14:20 -0600 Subject: [PATCH] Don't show resolved markets in hot markets --- web/lib/firebase/contracts.ts | 2 +- web/pages/index.tsx | 7 ++++--- web/pages/markets.tsx | 11 +++++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts index 4300a2db..4ce20dbe 100644 --- a/web/lib/firebase/contracts.ts +++ b/web/lib/firebase/contracts.ts @@ -146,7 +146,7 @@ export function computeHotContracts(recentBets: Bet[]) { const contractBets = _.groupBy(recentBets, (bet) => bet.contractId) const hotContractIds = _.sortBy(Object.keys(contractBets), (contractId) => _.sumBy(contractBets[contractId], (bet) => -1 * bet.amount) - ).slice(0, 4) + ) return hotContractIds } diff --git a/web/pages/index.tsx b/web/pages/index.tsx index 7896adc7..c16bb68b 100644 --- a/web/pages/index.tsx +++ b/web/pages/index.tsx @@ -32,9 +32,10 @@ const Home = (props: { contracts: Contract[]; hotContractIds: string[] }) => { if (user === undefined) return <> const { contracts, hotContractIds } = props - const hotContracts = hotContractIds.map( - (id) => contracts.find((contract) => contract.id === id) as Contract - ) + const hotContracts = hotContractIds + .map((id) => contracts.find((contract) => contract.id === id) as Contract) + .filter((contract) => !contract.isResolved) + .slice(0, 4) return user ? ( diff --git a/web/pages/markets.tsx b/web/pages/markets.tsx index f28c493d..6aa30cd0 100644 --- a/web/pages/markets.tsx +++ b/web/pages/markets.tsx @@ -39,10 +39,13 @@ export default function Markets(props: { hotContractIds === 'loading' ? props.hotContractIds : hotContractIds const readyContracts = contracts === 'loading' ? props.contracts : contracts - const hotContracts = readyHotContractIds.map( - (hotId) => - _.find(readyContracts, (contract) => contract.id === hotId) as Contract - ) + const hotContracts = readyHotContractIds + .map( + (hotId) => + _.find(readyContracts, (contract) => contract.id === hotId) as Contract + ) + .filter((contract) => !contract.isResolved) + .slice(0, 4) return (