Skip to content

Commit bb4e695

Browse files
Gargronhiyuki2578
authored andcommitted
Fix web UI crash on page load when detailed status has a poll (mastodon#10139)
1 parent 2c48af4 commit bb4e695

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • app/javascript/mastodon/components

app/javascript/mastodon/components/poll.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default @injectIntl
4545
class Poll extends ImmutablePureComponent {
4646

4747
static propTypes = {
48-
poll: ImmutablePropTypes.map.isRequired,
48+
poll: ImmutablePropTypes.map,
4949
intl: PropTypes.object.isRequired,
5050
dispatch: PropTypes.func,
5151
disabled: PropTypes.bool,
@@ -122,9 +122,14 @@ class Poll extends ImmutablePureComponent {
122122

123123
render () {
124124
const { poll, intl } = this.props;
125-
const timeRemaining = timeRemainingString(intl, new Date(poll.get('expires_at')), intl.now());
126-
const showResults = poll.get('voted') || poll.get('expired');
127-
const disabled = this.props.disabled || Object.entries(this.state.selected).every(item => !item);
125+
126+
if (!poll) {
127+
return null;
128+
}
129+
130+
const timeRemaining = timeRemainingString(intl, new Date(poll.get('expires_at')), intl.now());
131+
const showResults = poll.get('voted') || poll.get('expired');
132+
const disabled = this.props.disabled || Object.entries(this.state.selected).every(item => !item);
128133

129134
return (
130135
<div className='poll'>

0 commit comments

Comments
 (0)