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 98954fc2d95..472485a02cd 100644 --- a/app/javascript/mastodon/components/poll.tsx +++ b/app/javascript/mastodon/components/poll.tsx @@ -59,10 +59,13 @@ export const Poll: React.FC = ({ pollId, disabled, status }) => { return false; } const expiresAt = poll.expires_at; - return poll.expired || new Date(expiresAt).getTime() < Date.now(); + return ( + poll.expired || + (expiresAt !== null && new Date(expiresAt).getTime() < Date.now()) + ); }, [poll]); const timeRemaining = useMemo(() => { - if (!poll) { + if (!poll?.expires_at) { return null; } if (expired) {