From 0ff85f88fa536ef198fa02b60ca490e163621f82 Mon Sep 17 00:00:00 2001 From: marino <102478601+kemuru@users.noreply.github.com> Date: Fri, 20 Oct 2023 21:26:58 +0200 Subject: [PATCH] fix(web): crashing appeal tab --- web/src/hooks/useClassicAppealContext.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/web/src/hooks/useClassicAppealContext.tsx b/web/src/hooks/useClassicAppealContext.tsx index 2e1c22cf8..59b2890ab 100644 --- a/web/src/hooks/useClassicAppealContext.tsx +++ b/web/src/hooks/useClassicAppealContext.tsx @@ -99,11 +99,15 @@ export const useFundingContext = () => useContext(FundingContext); export const useOptionsContext = () => useContext(OptionsContext); const getCurrentLocalRound = (dispute?: ClassicAppealQuery["dispute"]) => { - const period = dispute?.period; - const currentLocalRoundIndex = dispute?.disputeKitDispute?.currentLocalRoundIndex; - return getLocalRounds(dispute?.disputeKitDispute)[ - ["appeal", "execution"].includes(period ?? "") ? currentLocalRoundIndex : currentLocalRoundIndex - 1 - ]; + if (!dispute) return undefined; + + const period = dispute.period; + const currentLocalRoundIndex = dispute.disputeKitDispute?.currentLocalRoundIndex; + const adjustedRoundIndex = ["appeal", "execution"].includes(period) + ? currentLocalRoundIndex + : currentLocalRoundIndex - 1; + + return getLocalRounds(dispute.disputeKitDispute)[adjustedRoundIndex]; }; const getPaidFees = (dispute?: ClassicAppealQuery["dispute"]) => {