From c156b6d69683c218773c91887411652c91a74012 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 3 Mar 2019 23:45:02 +0100 Subject: [PATCH] Fix web UI crash on page load when detailed status has a poll Port 21246d861e3746c19826570c3ece839fd0610991 to glitch-soc --- app/javascript/flavours/glitch/components/poll.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/javascript/flavours/glitch/components/poll.js b/app/javascript/flavours/glitch/components/poll.js index d4b9f283a3..c18ee1505b 100644 --- a/app/javascript/flavours/glitch/components/poll.js +++ b/app/javascript/flavours/glitch/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 (