Этот коммит содержится в:
nickago
2015-08-13 11:10:02 -07:00
родитель 7203128e99
Коммит 0de580b282

Просмотреть файл

@@ -13,7 +13,9 @@ var CHANGE_EVENT = 'change';
var utils; var utils;
function getWindowLocationOrigin() { function getWindowLocationOrigin() {
if (!utils) utils = require('../utils/utils.jsx'); if (!utils) {
utils = require('../utils/utils.jsx');
}
return utils.getWindowLocationOrigin(); return utils.getWindowLocationOrigin();
} }
@@ -28,15 +30,14 @@ var TeamStore = assign({}, EventEmitter.prototype, {
this.removeListener(CHANGE_EVENT, callback); this.removeListener(CHANGE_EVENT, callback);
}, },
get: function(id) { get: function(id) {
var c = this._getTeams(); var c = this.pGetTeams();
return c[id]; return c[id];
}, },
getByName: function(name) { getByName: function(name) {
var current = null; var t = this.pGetTeams();
var t = this._getTeams();
for (id in t) { for (var id in t) {
if (t[id].name == name) { if (t[id].name === name) {
return t[id]; return t[id];
} }
} }
@@ -44,48 +45,49 @@ var TeamStore = assign({}, EventEmitter.prototype, {
return null; return null;
}, },
getAll: function() { getAll: function() {
return this._getTeams(); return this.pGetTeams();
}, },
setCurrentId: function(id) { setCurrentId: function(id) {
if (id == null) if (id === null) {
BrowserStore.removeItem("current_team_id"); BrowserStore.removeItem('current_team_id');
else } else {
BrowserStore.setItem("current_team_id", id); BrowserStore.setItem('current_team_id', id);
}
}, },
getCurrentId: function() { getCurrentId: function() {
return BrowserStore.getItem("current_team_id"); return BrowserStore.getItem('current_team_id');
}, },
getCurrent: function() { getCurrent: function() {
var currentId = TeamStore.getCurrentId(); var currentId = TeamStore.getCurrentId();
if (currentId != null) if (currentId !== null) {
return this.get(currentId); return this.get(currentId);
else }
return null; return null;
}, },
getCurrentTeamUrl: function() { getCurrentTeamUrl: function() {
if(this.getCurrent()) { if (this.getCurrent()) {
return getWindowLocationOrigin() + "/" + this.getCurrent().name; return getWindowLocationOrigin() + '/' + this.getCurrent().name;
} }
return null; return null;
}, },
storeTeam: function(team) { storeTeam: function(team) {
var teams = this._getTeams(); var teams = this.pGetTeams();
teams[team.id] = team; teams[team.id] = team;
this._storeTeams(teams); this.pStoreTeams(teams);
}, },
_storeTeams: function(teams) { pStoreTeams: function(teams) {
BrowserStore.setItem("user_teams", teams); BrowserStore.setItem('user_teams', teams);
}, },
_getTeams: function() { pGetTeams: function() {
return BrowserStore.getItem("user_teams", {}); return BrowserStore.getItem('user_teams', {});
} }
}); });
TeamStore.dispatchToken = AppDispatcher.register(function(payload) { TeamStore.dispatchToken = AppDispatcher.register(function registry(payload) {
var action = payload.action; var action = payload.action;
switch(action.type) { switch (action.type) {
case ActionTypes.CLICK_TEAM: case ActionTypes.CLICK_TEAM:
TeamStore.setCurrentId(action.id); TeamStore.setCurrentId(action.id);