From 7203128e999fdd34c92352808ad506746ea64dad Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Thu, 13 Aug 2015 11:00:49 -0700
Subject: Added flux-style error protection on team store call in sidebar

---
 web/react/components/sidebar.jsx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'web/react/components/sidebar.jsx')

diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx
index fe73cbcf7..2f1e237ee 100644
--- a/web/react/components/sidebar.jsx
+++ b/web/react/components/sidebar.jsx
@@ -128,6 +128,7 @@ module.exports = React.createClass({
         ChannelStore.addChangeListener(this.onChange);
         UserStore.addChangeListener(this.onChange);
         UserStore.addStatusesChangeListener(this.onChange);
+        TeamStore.addChangeListener(this.onChange);
         SocketStore.addChangeListener(this.onSocketChange);
         $('.nav-pills__container').perfectScrollbar();
 
@@ -146,6 +147,7 @@ module.exports = React.createClass({
         ChannelStore.removeChangeListener(this.onChange);
         UserStore.removeChangeListener(this.onChange);
         UserStore.removeStatusesChangeListener(this.onChange);
+        TeamStore.removeChangeListener(this.onChange);
         SocketStore.removeChangeListener(this.onSocketChange);
     },
     onChange: function() {
@@ -346,15 +348,16 @@ module.exports = React.createClass({
 
             // set up click handler to switch channels (or create a new channel for non-existant ones)
             var clickHandler = null;
-            var href;
+            var href = '#';
+            var teamURL = TeamStore.getCurrentTeamUrl();
             if (!channel.fake) {
                 clickHandler = function(e) {
                     e.preventDefault();
                     utils.switchChannel(channel);
                 };
-                href = '#';
-            } else {
-                href = TeamStore.getCurrentTeamUrl() + '/channels/' + channel.name;
+            }
+            if (channel.fake && teamURL){
+                href = teamURL + '/channels/' + channel.name;
             }
 
             return (
-- 
cgit v1.2.3-1-g7c22

