diff --git a/web/components/answers/answers-panel.tsx b/web/components/answers/answers-panel.tsx index a1cef4c3..51cf5799 100644 --- a/web/components/answers/answers-panel.tsx +++ b/web/components/answers/answers-panel.tsx @@ -38,26 +38,13 @@ export function AnswersPanel(props: { 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((a) => (showAllAnswers ? true : totalBets[a.id] > 0)), - (answer) => - answer.id === resolution || (resolutions && resolutions[answer.id]) + const [winningAnswers, notWinningAnswers] = partition( + answers, + (a) => a.id === resolution || (resolutions && resolutions[a.id]) ) - const sortedAnswers = [ - ...sortBy(winningAnswers, (answer) => - resolutions ? -1 * resolutions[answer.id] : 0 - ), - ...sortBy( - resolution ? [] : losingAnswers, - (answer) => -1 * getDpmOutcomeProbability(contract.totalShares, answer.id) - ), - ] - - const answerItems = sortBy( - losingAnswers.length > 0 ? losingAnswers : sortedAnswers, - (answer) => -getOutcomeProbability(contract, answer.id) + const [visibleAnswers, invisibleAnswers] = partition( + sortBy(notWinningAnswers, (a) => -getOutcomeProbability(contract, a.id)), + (a) => showAllAnswers || totalBets[a.id] > 0 ) const user = useUser() @@ -107,13 +94,13 @@ export function AnswersPanel(props: { return ( {(resolveOption || resolution) && - sortedAnswers.map((answer) => ( + sortBy(winningAnswers, (a) => -(resolutions?.[a.id] ?? 0)).map((a) => ( - {answerItems.map((item) => ( - + {visibleAnswers.map((a) => ( + ))} - {hasZeroBetAnswers && !showAllAnswers && ( + {invisibleAnswers.length > 0 && !showAllAnswers && (