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

Port 42c01d703f to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire committed 2026-07-27 12:10:00 +02:00
1 parent a933248d85
commit 6e092a8d84
2 files changed
+3 -3

No files matched your search

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