From de8c27c97086ac9373fecdae00823f2d0dab124d Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Tue, 13 Sep 2022 07:48:41 -0600 Subject: [PATCH] Filter None answer earlier --- web/components/answers/answers-panel.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/web/components/answers/answers-panel.tsx b/web/components/answers/answers-panel.tsx index 7ab5e804..444c5701 100644 --- a/web/components/answers/answers-panel.tsx +++ b/web/components/answers/answers-panel.tsx @@ -33,15 +33,13 @@ export function AnswersPanel(props: { contract const [showAllAnswers, setShowAllAnswers] = useState(false) - const answers = useAnswers(contract.id) ?? contract.answers - const hasZeroBetAnswers = answers.some((answer) => totalBets[answer.id] === 0) + const answers = (useAnswers(contract.id) ?? contract.answers).filter( + (a) => a.number != 0 || contract.outcomeType === 'MULTIPLE_CHOICE' + ) + const hasZeroBetAnswers = answers.some((answer) => totalBets[answer.id] < 1) const [winningAnswers, losingAnswers] = partition( - answers.filter((answer) => - (answer.id !== '0' || outcomeType === 'MULTIPLE_CHOICE') && showAllAnswers - ? true - : totalBets[answer.id] > 0 - ), + answers.filter((a) => (showAllAnswers ? true : totalBets[a.id] > 0)), (answer) => answer.id === resolution || (resolutions && resolutions[answer.id]) )