Fix being unable to vote in polls without an expiration date (#39949)
This commit is contained in:
parent
8429b44b03
commit
027202b334
@ -9,7 +9,7 @@ export interface ApiPollOptionJSON {
|
|||||||
|
|
||||||
export interface ApiPollJSON {
|
export interface ApiPollJSON {
|
||||||
id: string;
|
id: string;
|
||||||
expires_at: string;
|
expires_at: string | null;
|
||||||
expired: boolean;
|
expired: boolean;
|
||||||
multiple: boolean;
|
multiple: boolean;
|
||||||
votes_count: number;
|
votes_count: number;
|
||||||
|
|||||||
@ -36,7 +36,7 @@ const messages = defineMessages({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const isPollExpired = (expiresAt: Model.Poll['expires_at']) =>
|
const isPollExpired = (expiresAt: Model.Poll['expires_at']) =>
|
||||||
new Date(expiresAt).getTime() < Date.now();
|
expiresAt !== null && new Date(expiresAt).getTime() < Date.now();
|
||||||
|
|
||||||
interface PollProps {
|
interface PollProps {
|
||||||
pollId: string;
|
pollId: string;
|
||||||
@ -64,7 +64,7 @@ export const Poll: React.FC<PollProps> = ({ pollId, disabled, status }) => {
|
|||||||
return poll.expired || isPollExpired(poll.expires_at);
|
return poll.expired || isPollExpired(poll.expires_at);
|
||||||
}, [poll]);
|
}, [poll]);
|
||||||
const timeRemaining = useMemo(() => {
|
const timeRemaining = useMemo(() => {
|
||||||
if (!poll) {
|
if (!poll?.expires_at) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (expired) {
|
if (expired) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user