Fix broken useBets
filters (#731)
This commit is contained in:
parent
e7f1d3924b
commit
592125b5e7
|
@ -14,21 +14,22 @@ export const useBets = (
|
||||||
options?: { filterChallenges: boolean; filterRedemptions: boolean }
|
options?: { filterChallenges: boolean; filterRedemptions: boolean }
|
||||||
) => {
|
) => {
|
||||||
const [bets, setBets] = useState<Bet[] | undefined>()
|
const [bets, setBets] = useState<Bet[] | undefined>()
|
||||||
|
const filterChallenges = !!options?.filterChallenges
|
||||||
|
const filterRedemptions = !!options?.filterRedemptions
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (contractId)
|
if (contractId)
|
||||||
return listenForBets(contractId, (bets) => {
|
return listenForBets(contractId, (bets) => {
|
||||||
if (options)
|
if (filterChallenges || filterRedemptions)
|
||||||
setBets(
|
setBets(
|
||||||
bets.filter(
|
bets.filter(
|
||||||
(bet) =>
|
(bet) =>
|
||||||
(options.filterChallenges ? !bet.challengeSlug : true) &&
|
(filterChallenges ? !bet.challengeSlug : true) &&
|
||||||
(options.filterRedemptions ? !bet.isRedemption : true)
|
(filterRedemptions ? !bet.isRedemption : true)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else setBets(bets)
|
else setBets(bets)
|
||||||
})
|
})
|
||||||
}, [contractId, options])
|
}, [contractId, filterChallenges, filterRedemptions])
|
||||||
|
|
||||||
return bets
|
return bets
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user