diff --git a/app/javascript/mastodon/api_types/polls.ts b/app/javascript/mastodon/api_types/polls.ts index 891a2faba7..1ff2a6a5cb 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 9ed15fbf15..a634743f72 100644 --- a/app/javascript/mastodon/components/poll.tsx +++ b/app/javascript/mastodon/components/poll.tsx @@ -35,7 +35,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; @@ -69,7 +69,7 @@ export const Poll: React.FC = ({ return poll.expired || isPollExpired(poll.expires_at); }, [poll]); const timeRemaining = useMemo(() => { - if (!poll) { + if (!poll?.expires_at) { return null; } if (expired) {