diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-03-03 23:45:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-03 23:45:02 +0100 |
commit | 5dfa4336985616cf5652de2f1cf794d8f740424e (patch) | |
tree | d6b7866919677fca08c5e889bedf437725adecd9 /app/javascript | |
parent | 26c56d0c10ca036291d8b08b34f971f981217e8c (diff) |
Fix web UI crash on page load when detailed status has a poll (#10139)
Diffstat (limited to 'app/javascript')
-rw-r--r-- | app/javascript/mastodon/components/poll.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/javascript/mastodon/components/poll.js b/app/javascript/mastodon/components/poll.js index d4b9f283a..c18ee1505 100644 --- a/app/javascript/mastodon/components/poll.js +++ b/app/javascript/mastodon/components/poll.js @@ -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, @@ -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'> |