From 3406ce043c875668800e430e4e4cd9f4c6669370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Miko=C5=82ajczak?= Date: Sun, 5 Nov 2023 14:46:05 +0100 Subject: [PATCH] Support infinite voting time for remote polls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Mikołajczak Signed-off-by: marcin mikołajczak --- src/components/polls/poll-footer.tsx | 10 ++++++---- src/schemas/poll.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/polls/poll-footer.tsx b/src/components/polls/poll-footer.tsx index b9a341c5e7..402216a715 100644 --- a/src/components/polls/poll-footer.tsx +++ b/src/components/polls/poll-footer.tsx @@ -33,9 +33,11 @@ const PollFooter: React.FC = ({ poll, showResults, selected }): JSX e.preventDefault(); }; - const timeRemaining = poll.expired ? - intl.formatMessage(messages.closed) : - ; + const timeRemaining = poll.expires_at && ( + poll.expired ? + intl.formatMessage(messages.closed) : + + ); let votesCount = null; @@ -82,7 +84,7 @@ const PollFooter: React.FC = ({ poll, showResults, selected }): JSX {votesCount} - {poll.expires_at && ( + {poll.expires_at !== null && ( <> · {timeRemaining} diff --git a/src/schemas/poll.ts b/src/schemas/poll.ts index 73d27753a7..65ead6e149 100644 --- a/src/schemas/poll.ts +++ b/src/schemas/poll.ts @@ -14,7 +14,7 @@ const pollOptionSchema = z.object({ const pollSchema = z.object({ emojis: filteredArray(customEmojiSchema), expired: z.boolean().catch(false), - expires_at: z.string().datetime().catch(new Date().toUTCString()), + expires_at: z.string().datetime().nullable().catch(null), id: z.string(), multiple: z.boolean().catch(false), options: z.array(pollOptionSchema).min(2),