From 650dda137f98c76b522f6370bb4d6ec99f267e9c Mon Sep 17 00:00:00 2001
From: noellabo <noel.yoshiba@gmail.com>
Date: Tue, 12 Nov 2019 14:09:06 +0900
Subject: [PATCH] Fix null poll

---
 app/javascript/mastodon/components/poll.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/app/javascript/mastodon/components/poll.js b/app/javascript/mastodon/components/poll.js
index 3a17e80e72..c678d797ea 100644
--- a/app/javascript/mastodon/components/poll.js
+++ b/app/javascript/mastodon/components/poll.js
@@ -39,6 +39,9 @@ class Poll extends ImmutablePureComponent {
 
   static getDerivedStateFromProps (props, state) {
     const { poll, intl } = props;
+    if (!poll) {
+      return null;
+    }
     const expires_at = poll.get('expires_at');
     const expired = poll.get('expired') || expires_at !== null && (new Date(expires_at)).getTime() < intl.now();
     return (expired === state.expired) ? null : { expired };
@@ -59,7 +62,7 @@ class Poll extends ImmutablePureComponent {
   _setupTimer () {
     const { poll, intl } = this.props;
     clearTimeout(this._timer);
-    if (!this.state.expired) {
+    if (!this.state.expired && !!poll) {
       const delay = (new Date(poll.get('expires_at'))).getTime() - intl.now();
       this._timer = setTimeout(() => {
         this.setState({ expired: true });
-- 
GitLab