From 693ee9e19fd3d668c0669b8bf492cff137b901fa Mon Sep 17 00:00:00 2001 From: ctrlc03 <93448202+ctrlc03@users.noreply.github.com> Date: Thu, 5 Sep 2024 12:34:03 +0100 Subject: [PATCH] fix: ensure poll end date is in the future --- packages/interface/src/contexts/Maci.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/interface/src/contexts/Maci.tsx b/packages/interface/src/contexts/Maci.tsx index 472e2742..bccde6d9 100644 --- a/packages/interface/src/contexts/Maci.tsx +++ b/packages/interface/src/contexts/Maci.tsx @@ -208,7 +208,10 @@ export const MaciProvider: React.FC = ({ children }: MaciProv // memo to calculate the voting end date const votingEndsAt = useMemo( - () => (pollData ? new Date(Number(pollData.deployTime) * 1000 + Number(pollData.duration) * 1000) : new Date()), + () => + pollData && pollData.duration !== 0 + ? new Date(Number(pollData.deployTime) * 1000 + Number(pollData.duration) * 1000) + : config.resultsAt, [pollData?.deployTime, pollData?.duration], ); @@ -397,7 +400,7 @@ export const MaciProvider: React.FC = ({ children }: MaciProv return data; }) .then(async (data) => { - if (!data.isMerged || isAfter(votingEndsAt, new Date())) { + if (!data.isMerged || isAfter(votingEndsAt!, new Date())) { return undefined; }