Cosmetic refactors, including variable name changes and splitting if statements
Этот коммит содержится в:
@@ -87,8 +87,7 @@ var NavbarDropdown = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
teams.push(<li key="newTeam_li"><a key="newTeam_a" href={utils.getWindowLocationOrigin() + "/signup_team" }>Create a New Team</a></li>);
|
teams.push(<li key='newTeam_li'><a key='newTeam_a' href={utils.getWindowLocationOrigin() + '/signup_team' }>Create a New Team</a></li>);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className='nav navbar-nav navbar-right'>
|
<ul className='nav navbar-nav navbar-right'>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var CHANGE_EVENT_STATUSES = 'change_statuses';
|
|||||||
|
|
||||||
var UserStore = assign({}, EventEmitter.prototype, {
|
var UserStore = assign({}, EventEmitter.prototype, {
|
||||||
|
|
||||||
_current_id: null,
|
gCurrentId: null,
|
||||||
|
|
||||||
emitChange: function(userId) {
|
emitChange: function(userId) {
|
||||||
this.emit(CHANGE_EVENT, userId);
|
this.emit(CHANGE_EVENT, userId);
|
||||||
@@ -65,21 +65,22 @@ var UserStore = assign({}, EventEmitter.prototype, {
|
|||||||
this.removeListener(CHANGE_EVENT_STATUSES, callback);
|
this.removeListener(CHANGE_EVENT_STATUSES, callback);
|
||||||
},
|
},
|
||||||
setCurrentId: function(id) {
|
setCurrentId: function(id) {
|
||||||
this._current_id = id;
|
this.gCurrentId = id;
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
BrowserStore.removeGlobalItem("current_user_id");
|
BrowserStore.removeGlobalItem('current_user_id');
|
||||||
} else {
|
} else {
|
||||||
BrowserStore.setGlobalItem("current_user_id", id);
|
BrowserStore.setGlobalItem('current_user_id', id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getCurrentId: function() {
|
getCurrentId: function() {
|
||||||
var current_id = this._current_id;
|
var currentId = this.gCurrentId;
|
||||||
|
|
||||||
if (current_id == null) {
|
if (currentId == null) {
|
||||||
current_id = BrowserStore.getGlobalItem("current_user_id");
|
currentId = BrowserStore.getGlobalItem('current_user_id');
|
||||||
|
this.gCurrentId = currentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return current_id;
|
return currentId;
|
||||||
},
|
},
|
||||||
getCurrentUser: function(skipFetch) {
|
getCurrentUser: function(skipFetch) {
|
||||||
if (this.getCurrentId(skipFetch) == null) {
|
if (this.getCurrentId(skipFetch) == null) {
|
||||||
@@ -93,10 +94,10 @@ var UserStore = assign({}, EventEmitter.prototype, {
|
|||||||
this.saveProfile(user);
|
this.saveProfile(user);
|
||||||
},
|
},
|
||||||
getLastEmail: function() {
|
getLastEmail: function() {
|
||||||
return BrowserStore.getItem("last_email", '');
|
return BrowserStore.getItem('last_email', '');
|
||||||
},
|
},
|
||||||
setLastEmail: function(email) {
|
setLastEmail: function(email) {
|
||||||
BrowserStore.setItem("last_email", email);
|
BrowserStore.setItem('last_email', email);
|
||||||
},
|
},
|
||||||
removeCurrentUser: function() {
|
removeCurrentUser: function() {
|
||||||
this.setCurrentId(null);
|
this.setCurrentId(null);
|
||||||
@@ -118,11 +119,11 @@ var UserStore = assign({}, EventEmitter.prototype, {
|
|||||||
return this._getProfiles();
|
return this._getProfiles();
|
||||||
},
|
},
|
||||||
getActiveOnlyProfiles: function() {
|
getActiveOnlyProfiles: function() {
|
||||||
active = {};
|
var active = {};
|
||||||
current = this._getProfiles();
|
var current = this._getProfiles();
|
||||||
|
|
||||||
for (var key in current) {
|
for (var key in current) {
|
||||||
if (current[key].delete_at == 0) {
|
if (current[key].delete_at === 0) {
|
||||||
active[key] = current[key];
|
active[key] = current[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,73 +136,85 @@ var UserStore = assign({}, EventEmitter.prototype, {
|
|||||||
this._storeProfiles(ps);
|
this._storeProfiles(ps);
|
||||||
},
|
},
|
||||||
_storeProfiles: function(profiles) {
|
_storeProfiles: function(profiles) {
|
||||||
BrowserStore.setItem("profiles", profiles);
|
BrowserStore.setItem('profiles', profiles);
|
||||||
var profileUsernameMap = {};
|
var profileUsernameMap = {};
|
||||||
for (var id in profiles) {
|
for (var id in profiles) {
|
||||||
profileUsernameMap[profiles[id].username] = profiles[id];
|
profileUsernameMap[profiles[id].username] = profiles[id];
|
||||||
}
|
}
|
||||||
BrowserStore.setItem("profileUsernameMap", profileUsernameMap);
|
BrowserStore.setItem('profileUsernameMap', profileUsernameMap);
|
||||||
},
|
},
|
||||||
_getProfiles: function() {
|
_getProfiles: function() {
|
||||||
return BrowserStore.getItem("profiles", {});
|
return BrowserStore.getItem('profiles', {});
|
||||||
},
|
},
|
||||||
_getProfilesUsernameMap: function() {
|
_getProfilesUsernameMap: function() {
|
||||||
return BrowserStore.getItem("profileUsernameMap", {});
|
return BrowserStore.getItem('profileUsernameMap', {});
|
||||||
},
|
},
|
||||||
setSessions: function(sessions) {
|
setSessions: function(sessions) {
|
||||||
BrowserStore.setItem("sessions", sessions);
|
BrowserStore.setItem('sessions', sessions);
|
||||||
},
|
},
|
||||||
getSessions: function() {
|
getSessions: function() {
|
||||||
return BrowserStore.getItem("sessions", {loading: true});
|
return BrowserStore.getItem('sessions', {loading: true});
|
||||||
},
|
},
|
||||||
setAudits: function(audits) {
|
setAudits: function(audits) {
|
||||||
BrowserStore.setItem("audits", audits);
|
BrowserStore.setItem('audits', audits);
|
||||||
},
|
},
|
||||||
getAudits: function() {
|
getAudits: function() {
|
||||||
return BrowserStore.getItem("audits", {loading: true});
|
return BrowserStore.getItem('audits', {loading: true});
|
||||||
},
|
},
|
||||||
setTeams: function(teams) {
|
setTeams: function(teams) {
|
||||||
BrowserStore.setItem("teams", teams);
|
BrowserStore.setItem('teams', teams);
|
||||||
},
|
},
|
||||||
getTeams: function() {
|
getTeams: function() {
|
||||||
return BrowserStore.getItem("teams", []);
|
return BrowserStore.getItem('teams', []);
|
||||||
},
|
},
|
||||||
getCurrentMentionKeys: function() {
|
getCurrentMentionKeys: function() {
|
||||||
var user = this.getCurrentUser();
|
var user = this.getCurrentUser();
|
||||||
|
|
||||||
var keys = [];
|
var keys = [];
|
||||||
|
|
||||||
if (!user)
|
if (!user || !user.notify_props) {
|
||||||
return keys;
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
if (user.notify_props && user.notify_props.mention_keys) keys = keys.concat(user.notify_props.mention_keys.split(','));
|
if (user.notify_props.mention_keys) {
|
||||||
if (user.first_name && user.notify_props.first_name === "true") keys.push(user.first_name);
|
keys = keys.concat(user.notify_props.mention_keys.split(','));
|
||||||
if (user.notify_props.all === "true") keys.push('@all');
|
}
|
||||||
if (user.notify_props.channel === "true") keys.push('@channel');
|
|
||||||
|
if (user.notify_props.first_name === 'true' && user.first_name) {
|
||||||
|
keys.push(user.first_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.notify_props.all === 'true') {
|
||||||
|
keys.push('@all');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.notify_props.channel === 'true') {
|
||||||
|
keys.push('@channel');
|
||||||
|
}
|
||||||
|
|
||||||
return keys;
|
return keys;
|
||||||
},
|
},
|
||||||
getLastVersion: function() {
|
getLastVersion: function() {
|
||||||
return BrowserStore.getItem("last_version", '');
|
return BrowserStore.getItem('last_version', '');
|
||||||
},
|
},
|
||||||
setLastVersion: function(version) {
|
setLastVersion: function(version) {
|
||||||
BrowserStore.setItem("last_version", version);
|
BrowserStore.setItem('last_version', version);
|
||||||
},
|
},
|
||||||
setStatuses: function(statuses) {
|
setStatuses: function(statuses) {
|
||||||
this._setStatuses(statuses);
|
this._setStatuses(statuses);
|
||||||
this.emitStatusesChange();
|
this.emitStatusesChange();
|
||||||
},
|
},
|
||||||
_setStatuses: function(statuses) {
|
_setStatuses: function(statuses) {
|
||||||
BrowserStore.setItem("statuses", statuses);
|
BrowserStore.setItem('statuses', statuses);
|
||||||
},
|
},
|
||||||
setStatus: function(user_id, status) {
|
setStatus: function(userId, status) {
|
||||||
var statuses = this.getStatuses();
|
var statuses = this.getStatuses();
|
||||||
statuses[user_id] = status;
|
statuses[userId] = status;
|
||||||
this._setStatuses(statuses);
|
this._setStatuses(statuses);
|
||||||
this.emitStatusesChange();
|
this.emitStatusesChange();
|
||||||
},
|
},
|
||||||
getStatuses: function() {
|
getStatuses: function() {
|
||||||
return BrowserStore.getItem("statuses", {});
|
return BrowserStore.getItem('statuses', {});
|
||||||
},
|
},
|
||||||
getStatus: function(id) {
|
getStatus: function(id) {
|
||||||
return this.getStatuses()[id];
|
return this.getStatuses()[id];
|
||||||
@@ -215,7 +228,9 @@ UserStore.dispatchToken = AppDispatcher.register(function(payload) {
|
|||||||
case ActionTypes.RECIEVED_PROFILES:
|
case ActionTypes.RECIEVED_PROFILES:
|
||||||
for (var id in action.profiles) {
|
for (var id in action.profiles) {
|
||||||
// profiles can have incomplete data, so don't overwrite current user
|
// profiles can have incomplete data, so don't overwrite current user
|
||||||
if (id === UserStore.getCurrentId()) continue;
|
if (id === UserStore.getCurrentId()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var profile = action.profiles[id];
|
var profile = action.profiles[id];
|
||||||
UserStore.saveProfile(profile);
|
UserStore.saveProfile(profile);
|
||||||
UserStore.emitChange(profile.id);
|
UserStore.emitChange(profile.id);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user