about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-03 23:45:02 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-05 21:35:03 +0100
commitf14eda23e97c2f70b9d060f7575ed2801e5f1f5d (patch)
tree3ec18bd47f61425b94f439ef1ea2a3d2203b9e5a /app
parent2156765448f3abe295aa39cac382de7748f1aa11 (diff)
Fix web UI crash on page load when detailed status has a poll
Port 5dfa4336985616cf5652de2f1cf794d8f740424e to glitch-soc
Diffstat (limited to 'app')
-rw-r--r--app/javascript/flavours/glitch/components/poll.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/javascript/flavours/glitch/components/poll.js b/app/javascript/flavours/glitch/components/poll.js
index d4b9f283a..c18ee1505 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 (
       <div className='poll'>