summaryrefslogtreecommitdiffstats
path: root/web/react
diff options
context:
space:
mode:
authornickago <ngonella@calpoly.edu>2015-08-13 11:00:49 -0700
committernickago <ngonella@calpoly.edu>2015-08-13 11:00:49 -0700
commit7203128e999fdd34c92352808ad506746ea64dad (patch)
treeb6fa3b76df5d214f0140dced2b2688c21b2e6d02 /web/react
parent6d9e715e265a3265841bc351e6b22a4503c20c92 (diff)
downloadchat-7203128e999fdd34c92352808ad506746ea64dad.tar.gz
chat-7203128e999fdd34c92352808ad506746ea64dad.tar.bz2
chat-7203128e999fdd34c92352808ad506746ea64dad.zip
Added flux-style error protection on team store call in sidebar
Diffstat (limited to 'web/react')
-rw-r--r--web/react/components/sidebar.jsx11
-rw-r--r--web/react/stores/team_store.jsx5
2 files changed, 11 insertions, 5 deletions
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 (
diff --git a/web/react/stores/team_store.jsx b/web/react/stores/team_store.jsx
index e6380d19e..0193d181b 100644
--- a/web/react/stores/team_store.jsx
+++ b/web/react/stores/team_store.jsx
@@ -64,7 +64,10 @@ var TeamStore = assign({}, EventEmitter.prototype, {
return null;
},
getCurrentTeamUrl: function() {
- return getWindowLocationOrigin() + "/" + this.getCurrent().name;
+ if(this.getCurrent()) {
+ return getWindowLocationOrigin() + "/" + this.getCurrent().name;
+ }
+ return null;
},
storeTeam: function(team) {
var teams = this._getTeams();