Skip to content

Commit

Permalink
Fix web UI crash on page load when detailed status has a poll (mastod…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and hiyuki2578 committed Oct 2, 2019
1 parent 2c48af4 commit bb4e695
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/javascript/mastodon/components/poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default @injectIntl
class Poll extends ImmutablePureComponent {

static propTypes = {
poll: ImmutablePropTypes.map.isRequired,
poll: ImmutablePropTypes.map,
intl: PropTypes.object.isRequired,
dispatch: PropTypes.func,
disabled: PropTypes.bool,
Expand Down Expand Up @@ -122,9 +122,14 @@ class Poll extends ImmutablePureComponent {

render () {
const { poll, intl } = this.props;
const timeRemaining = timeRemainingString(intl, new Date(poll.get('expires_at')), intl.now());
const showResults = poll.get('voted') || poll.get('expired');
const disabled = this.props.disabled || Object.entries(this.state.selected).every(item => !item);

if (!poll) {
return null;
}

const timeRemaining = timeRemainingString(intl, new Date(poll.get('expires_at')), intl.now());
const showResults = poll.get('voted') || poll.get('expired');
const disabled = this.props.disabled || Object.entries(this.state.selected).every(item => !item);

return (
<div className='poll'>
Expand Down

0 comments on commit bb4e695

Please sign in to comment.