Fix web UI crash on page load when detailed status has a poll (#10139)
This commit is contained in:
		
							parent
							
								
									26c56d0c10
								
							
						
					
					
						commit
						5dfa433698
					
				
					 1 changed files with 9 additions and 4 deletions
				
			
		| 
						 | 
					@ -45,7 +45,7 @@ export default @injectIntl
 | 
				
			||||||
class Poll extends ImmutablePureComponent {
 | 
					class Poll extends ImmutablePureComponent {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  static propTypes = {
 | 
					  static propTypes = {
 | 
				
			||||||
    poll: ImmutablePropTypes.map.isRequired,
 | 
					    poll: ImmutablePropTypes.map,
 | 
				
			||||||
    intl: PropTypes.object.isRequired,
 | 
					    intl: PropTypes.object.isRequired,
 | 
				
			||||||
    dispatch: PropTypes.func,
 | 
					    dispatch: PropTypes.func,
 | 
				
			||||||
    disabled: PropTypes.bool,
 | 
					    disabled: PropTypes.bool,
 | 
				
			||||||
| 
						 | 
					@ -122,9 +122,14 @@ class Poll extends ImmutablePureComponent {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  render () {
 | 
					  render () {
 | 
				
			||||||
    const { poll, intl } = this.props;
 | 
					    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');
 | 
					    if (!poll) {
 | 
				
			||||||
    const disabled       = this.props.disabled || Object.entries(this.state.selected).every(item => !item);
 | 
					      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 (
 | 
					    return (
 | 
				
			||||||
      <div className='poll'>
 | 
					      <div className='poll'>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue