From 9e5f298350d9b05dbb60ba122cd8cb72d40c8997 Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 27 Jul 2026 11:46:27 +0200 Subject: [PATCH] Fix being unable to vote in polls without an expiration date (#39949) --- app/javascript/mastodon/api_types/polls.ts | 2 +- app/javascript/mastodon/components/poll.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/javascript/mastodon/api_types/polls.ts b/app/javascript/mastodon/api_types/polls.ts index 891a2faba79..1ff2a6a5cba 100644 --- a/app/javascript/mastodon/api_types/polls.ts +++ b/app/javascript/mastodon/api_types/polls.ts @@ -9,7 +9,7 @@ export interface ApiPollOptionJSON { export interface ApiPollJSON { id: string; - expires_at: string; + expires_at: string | null; expired: boolean; multiple: boolean; votes_count: number; diff --git a/app/javascript/mastodon/components/poll.tsx b/app/javascript/mastodon/components/poll.tsx index c77ce8bcee7..443022c0031 100644 --- a/app/javascript/mastodon/components/poll.tsx +++ b/app/javascript/mastodon/components/poll.tsx @@ -36,7 +36,7 @@ const messages = defineMessages({ }); const isPollExpired = (expiresAt: Model.Poll['expires_at']) => - new Date(expiresAt).getTime() < Date.now(); + expiresAt !== null && new Date(expiresAt).getTime() < Date.now(); interface PollProps { pollId: string; @@ -64,7 +64,7 @@ export const Poll: React.FC = ({ pollId, disabled, status }) => { return poll.expired || isPollExpired(poll.expires_at); }, [poll]); const timeRemaining = useMemo(() => { - if (!poll) { + if (!poll?.expires_at) { return null; } if (expired) {