From 041bfe5ac0bf43e982508441f12c83ce11859e9e Mon Sep 17 00:00:00 2001 From: James Grugett Date: Mon, 7 Feb 2022 23:43:35 -0600 Subject: [PATCH] Fix latestTime graph calculation --- web/components/contract-prob-graph.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web/components/contract-prob-graph.tsx b/web/components/contract-prob-graph.tsx index 3edab2a6..fceffd97 100644 --- a/web/components/contract-prob-graph.tsx +++ b/web/components/contract-prob-graph.tsx @@ -22,13 +22,16 @@ export function ContractProbGraph(props: { contract: Contract }) { ].map((time) => new Date(time)) const probs = [startProb, ...bets.map((bet) => bet.probAfter)] + const isClosed = !!closeTime && Date.now() > closeTime const latestTime = dayjs( - resolutionTime && closeTime + resolutionTime && isClosed ? Math.min(resolutionTime, closeTime) - : closeTime ?? resolutionTime ?? Date.now() + : isClosed + ? closeTime + : resolutionTime ?? Date.now() ) - if (resolutionTime) { + if (resolutionTime || isClosed) { times.push(latestTime.toDate()) probs.push(probs[probs.length - 1]) } else {