From 592125b5e7eec06af499ef0380c663866a27fec0 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 9 Aug 2022 08:50:11 -0700 Subject: [PATCH] Fix broken `useBets` filters (#731) --- web/hooks/use-bets.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/web/hooks/use-bets.ts b/web/hooks/use-bets.ts index 38b73dd1..9155d25e 100644 --- a/web/hooks/use-bets.ts +++ b/web/hooks/use-bets.ts @@ -14,21 +14,22 @@ export const useBets = ( options?: { filterChallenges: boolean; filterRedemptions: boolean } ) => { const [bets, setBets] = useState() - + const filterChallenges = !!options?.filterChallenges + const filterRedemptions = !!options?.filterRedemptions useEffect(() => { if (contractId) return listenForBets(contractId, (bets) => { - if (options) + if (filterChallenges || filterRedemptions) setBets( bets.filter( (bet) => - (options.filterChallenges ? !bet.challengeSlug : true) && - (options.filterRedemptions ? !bet.isRedemption : true) + (filterChallenges ? !bet.challengeSlug : true) && + (filterRedemptions ? !bet.isRedemption : true) ) ) else setBets(bets) }) - }, [contractId, options]) + }, [contractId, filterChallenges, filterRedemptions]) return bets }