From 7ce09ae39d2cbb817c428bd476ce5d61c9766e83 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Wed, 5 Oct 2022 19:23:47 -0500 Subject: [PATCH] midterms: use null in static props --- web/components/usa-map/state-election-map.tsx | 15 +++++++++------ web/pages/midterms.tsx | 8 ++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/web/components/usa-map/state-election-map.tsx b/web/components/usa-map/state-election-map.tsx index ac642fa0..a9a53a91 100644 --- a/web/components/usa-map/state-election-map.tsx +++ b/web/components/usa-map/state-election-map.tsx @@ -59,13 +59,16 @@ const useUpdateContracts = ( if (contracts.some((c) => c === undefined)) return // listen to contract updates - const unsubs = contracts.map((c, i) => - listenForContract( - c.id, - (newC) => - newC && setContracts(setAt(contracts, i, newC as CPMMBinaryContract)) + const unsubs = contracts + .filter((c) => !!c) + .map((c, i) => + listenForContract( + c.id, + (newC) => + newC && + setContracts(setAt(contracts, i, newC as CPMMBinaryContract)) + ) ) - ) return () => unsubs.forEach((u) => u()) }, [contracts, setContracts]) diff --git a/web/pages/midterms.tsx b/web/pages/midterms.tsx index 77efc7fd..d14f9d0f 100644 --- a/web/pages/midterms.tsx +++ b/web/pages/midterms.tsx @@ -180,11 +180,15 @@ const governorMidterms: StateElectionMarket[] = [ export async function getStaticProps() { const senateContracts = await Promise.all( - senateMidterms.map((m) => getContractFromSlug(m.slug)) + senateMidterms.map((m) => + getContractFromSlug(m.slug).then((c) => c ?? null) + ) ) const governorContracts = await Promise.all( - governorMidterms.map((m) => getContractFromSlug(m.slug)) + governorMidterms.map((m) => + getContractFromSlug(m.slug).then((c) => c ?? null) + ) ) return {