Fix web UI crash on page load when detailed status has a poll

Port 21246d861e to glitch-soc
lolsob-rspec
Eugen Rochko 2019-03-03 23:45:02 +01:00 committed by Thibaut Girka
parent e31450e8ad
commit c156b6d696
1 changed files with 9 additions and 4 deletions

View File

@ -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,6 +122,11 @@ class Poll extends ImmutablePureComponent {
render () {
const { poll, intl } = this.props;
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);