Skip to content

Commit

Permalink
fix: ensure poll end date is in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrlc03 authored and kittybest committed Sep 5, 2024
1 parent 71071b4 commit 693ee9e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/interface/src/contexts/Maci.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ export const MaciProvider: React.FC<MaciProviderProps> = ({ 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],
);

Expand Down Expand Up @@ -397,7 +400,7 @@ export const MaciProvider: React.FC<MaciProviderProps> = ({ children }: MaciProv
return data;
})
.then(async (data) => {
if (!data.isMerged || isAfter(votingEndsAt, new Date())) {
if (!data.isMerged || isAfter(votingEndsAt!, new Date())) {
return undefined;
}

Expand Down

0 comments on commit 693ee9e

Please sign in to comment.