[Glitch] Fix being unable to vote in polls without an expiration date

Port 42c01d703fdb87abd8c335624b83f2ac251967ac to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire 2026-07-27 11:46:27 +02:00 committed by Tarrien
parent 2921233163
commit 90553a2f33
2 changed files with 3 additions and 3 deletions

View File

@ -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;

View File

@ -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<PollProps> = ({ pollId, disabled, status }) => {
return poll.expired || isPollExpired(poll.expires_at);
}, [poll]);
const timeRemaining = useMemo(() => {
if (!poll) {
if (!poll?.expires_at) {
return null;
}
if (expired) {