about summary refs log tree commit diff
path: root/app/javascript/mastodon/features/community_timeline/index.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2022-10-08 07:15:50 +0200
committerGitHub <noreply@github.com>2022-10-08 07:15:50 +0200
commitd4b0aa74500419730525025b05513235aa477841 (patch)
tree1064fdec55966b0b6a291f7901aef1608305577d /app/javascript/mastodon/features/community_timeline/index.js
parentd84c53e76932abf79e07c8abe46c81acb77300d8 (diff)
Fix trying to connect to streaming API when logged out in web UI (#19316)
Diffstat (limited to 'app/javascript/mastodon/features/community_timeline/index.js')
-rw-r--r--app/javascript/mastodon/features/community_timeline/index.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/app/javascript/mastodon/features/community_timeline/index.js b/app/javascript/mastodon/features/community_timeline/index.js
index f9d50e64c..8fa372de4 100644
--- a/app/javascript/mastodon/features/community_timeline/index.js
+++ b/app/javascript/mastodon/features/community_timeline/index.js
@@ -35,6 +35,7 @@ class CommunityTimeline extends React.PureComponent {
 
   static contextTypes = {
     router: PropTypes.object,
+    identity: PropTypes.object,
   };
 
   static defaultProps = {
@@ -71,18 +72,30 @@ class CommunityTimeline extends React.PureComponent {
 
   componentDidMount () {
     const { dispatch, onlyMedia } = this.props;
+    const { signedIn } = this.context.identity;
 
     dispatch(expandCommunityTimeline({ onlyMedia }));
-    this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
+
+    if (signedIn) {
+      this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
+    }
   }
 
   componentDidUpdate (prevProps) {
+    const { signedIn } = this.context.identity;
+
     if (prevProps.onlyMedia !== this.props.onlyMedia) {
       const { dispatch, onlyMedia } = this.props;
 
-      this.disconnect();
+      if (this.disconnect) {
+        this.disconnect();
+      }
+
       dispatch(expandCommunityTimeline({ onlyMedia }));
-      this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
+
+      if (signedIn) {
+        this.disconnect = dispatch(connectCommunityStream({ onlyMedia }));
+      }
     }
   }