Skip to content

Commit

Permalink
Fix using Date.now() instead of intl.now() (mastodon#25234)
Browse files Browse the repository at this point in the history
  • Loading branch information
S-H-GAMELINKS committed Jun 1, 2023
1 parent 942d850 commit b3f9a0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/javascript/mastodon/components/poll.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class Poll extends ImmutablePureComponent {
};

static getDerivedStateFromProps (props, state) {
const { poll, intl } = props;
const { poll } = props;
const expires_at = poll.get('expires_at');
const expired = poll.get('expired') || expires_at !== null && (new Date(expires_at)).getTime() < intl.now();
const expired = poll.get('expired') || expires_at !== null && (new Date(expires_at)).getTime() < Date.now();
return (expired === state.expired) ? null : { expired };
}

Expand All @@ -76,10 +76,10 @@ class Poll extends ImmutablePureComponent {
}

_setupTimer () {
const { poll, intl } = this.props;
const { poll } = this.props;
clearTimeout(this._timer);
if (!this.state.expired) {
const delay = (new Date(poll.get('expires_at'))).getTime() - intl.now();
const delay = (new Date(poll.get('expires_at'))).getTime() - Date.now();
this._timer = setTimeout(() => {
this.setState({ expired: true });
}, delay);
Expand Down

0 comments on commit b3f9a0d

Please sign in to comment.