summaryrefslogtreecommitdiffstats
path: root/web/react/stores/team_store.jsx
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2015-06-18 12:13:56 -0400
committerJoramWilander <jwawilander@gmail.com>2015-06-18 12:13:56 -0400
commit4af08121e6ad32fe8ab228f2a64b139a62275b3c (patch)
tree8239cf101b9c731b7560bcc79cbadbdc873f95e6 /web/react/stores/team_store.jsx
parent19d823f29be0ad4111c37dae3beba97fcffa6ee0 (diff)
downloadchat-4af08121e6ad32fe8ab228f2a64b139a62275b3c.tar.gz
chat-4af08121e6ad32fe8ab228f2a64b139a62275b3c.tar.bz2
chat-4af08121e6ad32fe8ab228f2a64b139a62275b3c.zip
fix command comparator and team store
Diffstat (limited to 'web/react/stores/team_store.jsx')
-rw-r--r--web/react/stores/team_store.jsx38
1 files changed, 12 insertions, 26 deletions
diff --git a/web/react/stores/team_store.jsx b/web/react/stores/team_store.jsx
index e29106b22..e95daeeba 100644
--- a/web/react/stores/team_store.jsx
+++ b/web/react/stores/team_store.jsx
@@ -22,35 +22,20 @@ var TeamStore = assign({}, EventEmitter.prototype, {
this.removeListener(CHANGE_EVENT, callback);
},
get: function(id) {
- var current = null;
var c = this._getTeams();
-
- c.some(function(team) {
- if (team.id == id) {
- current = team;
- return true;
- }
- return false;
- });
-
- return current;
+ return c[id];
},
getByName: function(name) {
var current = null;
- var c = this._getTeams();
-
- c.some(function(team) {
- if (team.name == name) {
- current = team;
- return true;
- }
+ var t = this._getTeams();
- return false;
-
- });
-
- return current;
+ for (id in t) {
+ if (t[id].name == name) {
+ return t[id];
+ }
+ }
+ return null;
},
getAll: function() {
return this._getTeams();
@@ -78,12 +63,13 @@ var TeamStore = assign({}, EventEmitter.prototype, {
this._storeTeams(teams);
},
_storeTeams: function(teams) {
- sessionStorage.setItem("teams", JSON.stringify(teams));
+ sessionStorage.setItem("user_teams", JSON.stringify(teams));
},
_getTeams: function() {
- var teams = [];
+ var teams = {};
+
try {
- teams = JSON.parse(sessionStorage.teams);
+ teams = JSON.parse(sessionStorage.user_teams);
}
catch (err) {
}