From b640114edd1abb7e9938e0583b8a5a9e0c6c2383 Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Wed, 28 Sep 2016 08:43:22 -0400
Subject: Check if user logged in before making setActiveChannel request
 (#4097)

---
 webapp/components/post_view/post_view_cache.jsx | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

(limited to 'webapp/components/post_view/post_view_cache.jsx')

diff --git a/webapp/components/post_view/post_view_cache.jsx b/webapp/components/post_view/post_view_cache.jsx
index 8ed225e4b..c1b278c35 100644
--- a/webapp/components/post_view/post_view_cache.jsx
+++ b/webapp/components/post_view/post_view_cache.jsx
@@ -4,6 +4,7 @@
 import PostViewController from './post_view_controller.jsx';
 
 import ChannelStore from 'stores/channel_store.jsx';
+import UserStore from 'stores/user_store.jsx';
 import * as AsyncClient from 'utils/async_client.jsx';
 
 import React from 'react';
@@ -29,7 +30,9 @@ export default class PostViewCache extends React.Component {
     }
 
     componentWillUnmount() {
-        AsyncClient.setActiveChannel('');
+        if (UserStore.getCurrentUser()) {
+            AsyncClient.setActiveChannel('');
+        }
         ChannelStore.removeChangeListener(this.onChannelChange);
     }
 
-- 
cgit v1.2.3-1-g7c22

