Merge pull request #350 from nickago/MM-1684
MM-1684 Refactored code to remove errors on startup
Этот коммит содержится в:
@@ -439,7 +439,7 @@ module.exports = React.createClass({
|
|||||||
currentPostDay = utils.getDateForUnixTicks(post.create_at);
|
currentPostDay = utils.getDateForUnixTicks(post.create_at);
|
||||||
if (currentPostDay.toDateString() != previousPostDay.toDateString()) {
|
if (currentPostDay.toDateString() != previousPostDay.toDateString()) {
|
||||||
postCtls.push(
|
postCtls.push(
|
||||||
<div className="date-separator">
|
<div key={currentPostDay.toDateString()} className="date-separator">
|
||||||
<hr className="separator__hr" />
|
<hr className="separator__hr" />
|
||||||
<div className="separator__text">{currentPostDay.toDateString()}</div>
|
<div className="separator__text">{currentPostDay.toDateString()}</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -449,7 +449,7 @@ module.exports = React.createClass({
|
|||||||
if (post.create_at > last_viewed && !rendered_last_viewed) {
|
if (post.create_at > last_viewed && !rendered_last_viewed) {
|
||||||
rendered_last_viewed = true;
|
rendered_last_viewed = true;
|
||||||
postCtls.push(
|
postCtls.push(
|
||||||
<div className="new-separator">
|
<div key="unviewed" className="new-separator">
|
||||||
<hr id="new_message" className="separator__hr" />
|
<hr id="new_message" className="separator__hr" />
|
||||||
<div className="separator__text">New Messages</div>
|
<div className="separator__text">New Messages</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
var utils = require('../utils/utils.jsx');
|
var utils = require('../utils/utils.jsx');
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
|
displayName:'SettingsSidebar',
|
||||||
updateTab: function(tab) {
|
updateTab: function(tab) {
|
||||||
this.props.updateTab(tab);
|
this.props.updateTab(tab);
|
||||||
$('.settings-modal').addClass('display--content');
|
$('.settings-modal').addClass('display--content');
|
||||||
@@ -14,7 +15,7 @@ module.exports = React.createClass({
|
|||||||
<div className="">
|
<div className="">
|
||||||
<ul className="nav nav-pills nav-stacked">
|
<ul className="nav nav-pills nav-stacked">
|
||||||
{this.props.tabs.map(function(tab) {
|
{this.props.tabs.map(function(tab) {
|
||||||
return <li className={self.props.activeTab == tab.name ? 'active' : ''}><a href="#" onClick={function(){self.updateTab(tab.name);}}><i className={tab.icon}></i>{tab.ui_name}</a></li>
|
return <li key={tab.name+'_li'} className={self.props.activeTab == tab.name ? 'active' : ''}><a key={tab.name + '_a'} href="#" onClick={function(){self.updateTab(tab.name);}}><i key={tab.name+'_i'} className={tab.icon}></i>{tab.ui_name}</a></li>
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ var NavbarDropdown = React.createClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
teams.push(<li><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'>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var assign = require('object-assign');
|
var assign = require('object-assign');
|
||||||
var client = require('../utils/client.jsx');
|
|
||||||
|
|
||||||
var Constants = require('../utils/constants.jsx');
|
var Constants = require('../utils/constants.jsx');
|
||||||
var ActionTypes = Constants.ActionTypes;
|
var ActionTypes = Constants.ActionTypes;
|
||||||
@@ -18,244 +17,248 @@ 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);
|
||||||
},
|
},
|
||||||
addChangeListener: function(callback) {
|
addChangeListener: function(callback) {
|
||||||
this.on(CHANGE_EVENT, callback);
|
this.on(CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
removeChangeListener: function(callback) {
|
removeChangeListener: function(callback) {
|
||||||
this.removeListener(CHANGE_EVENT, callback);
|
this.removeListener(CHANGE_EVENT, callback);
|
||||||
},
|
},
|
||||||
emitSessionsChange: function() {
|
emitSessionsChange: function() {
|
||||||
this.emit(CHANGE_EVENT_SESSIONS);
|
this.emit(CHANGE_EVENT_SESSIONS);
|
||||||
},
|
},
|
||||||
addSessionsChangeListener: function(callback) {
|
addSessionsChangeListener: function(callback) {
|
||||||
this.on(CHANGE_EVENT_SESSIONS, callback);
|
this.on(CHANGE_EVENT_SESSIONS, callback);
|
||||||
},
|
},
|
||||||
removeSessionsChangeListener: function(callback) {
|
removeSessionsChangeListener: function(callback) {
|
||||||
this.removeListener(CHANGE_EVENT_SESSIONS, callback);
|
this.removeListener(CHANGE_EVENT_SESSIONS, callback);
|
||||||
},
|
},
|
||||||
emitAuditsChange: function() {
|
emitAuditsChange: function() {
|
||||||
this.emit(CHANGE_EVENT_AUDITS);
|
this.emit(CHANGE_EVENT_AUDITS);
|
||||||
},
|
},
|
||||||
addAuditsChangeListener: function(callback) {
|
addAuditsChangeListener: function(callback) {
|
||||||
this.on(CHANGE_EVENT_AUDITS, callback);
|
this.on(CHANGE_EVENT_AUDITS, callback);
|
||||||
},
|
},
|
||||||
removeAuditsChangeListener: function(callback) {
|
removeAuditsChangeListener: function(callback) {
|
||||||
this.removeListener(CHANGE_EVENT_AUDITS, callback);
|
this.removeListener(CHANGE_EVENT_AUDITS, callback);
|
||||||
},
|
},
|
||||||
emitTeamsChange: function() {
|
emitTeamsChange: function() {
|
||||||
this.emit(CHANGE_EVENT_TEAMS);
|
this.emit(CHANGE_EVENT_TEAMS);
|
||||||
},
|
},
|
||||||
addTeamsChangeListener: function(callback) {
|
addTeamsChangeListener: function(callback) {
|
||||||
this.on(CHANGE_EVENT_TEAMS, callback);
|
this.on(CHANGE_EVENT_TEAMS, callback);
|
||||||
},
|
},
|
||||||
removeTeamsChangeListener: function(callback) {
|
removeTeamsChangeListener: function(callback) {
|
||||||
this.removeListener(CHANGE_EVENT_TEAMS, callback);
|
this.removeListener(CHANGE_EVENT_TEAMS, callback);
|
||||||
},
|
},
|
||||||
emitStatusesChange: function() {
|
emitStatusesChange: function() {
|
||||||
this.emit(CHANGE_EVENT_STATUSES);
|
this.emit(CHANGE_EVENT_STATUSES);
|
||||||
},
|
},
|
||||||
addStatusesChangeListener: function(callback) {
|
addStatusesChangeListener: function(callback) {
|
||||||
this.on(CHANGE_EVENT_STATUSES, callback);
|
this.on(CHANGE_EVENT_STATUSES, callback);
|
||||||
},
|
},
|
||||||
removeStatusesChangeListener: function(callback) {
|
removeStatusesChangeListener: function(callback) {
|
||||||
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(skipFetch) {
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
// this is a speical case to force fetch the
|
return currentId;
|
||||||
// current user if it's missing
|
},
|
||||||
// it's synchronous to block rendering
|
getCurrentUser: function() {
|
||||||
if (current_id == null && !skipFetch) {
|
if (this.getCurrentId() == null) {
|
||||||
var me = client.getMeSynchronous();
|
return null;
|
||||||
if (me != null) {
|
}
|
||||||
this.setCurrentUser(me);
|
|
||||||
current_id = me.id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return current_id;
|
return this._getProfiles()[this.getCurrentId()];
|
||||||
},
|
},
|
||||||
getCurrentUser: function(skipFetch) {
|
setCurrentUser: function(user) {
|
||||||
if (this.getCurrentId(skipFetch) == null) {
|
this.setCurrentId(user.id);
|
||||||
return null;
|
this.saveProfile(user);
|
||||||
}
|
},
|
||||||
|
getLastEmail: function() {
|
||||||
|
return BrowserStore.getItem('last_email', '');
|
||||||
|
},
|
||||||
|
setLastEmail: function(email) {
|
||||||
|
BrowserStore.setItem('last_email', email);
|
||||||
|
},
|
||||||
|
removeCurrentUser: function() {
|
||||||
|
this.setCurrentId(null);
|
||||||
|
},
|
||||||
|
hasProfile: function(userId) {
|
||||||
|
return this._getProfiles()[userId] != null;
|
||||||
|
},
|
||||||
|
getProfile: function(userId) {
|
||||||
|
return this._getProfiles()[userId];
|
||||||
|
},
|
||||||
|
getProfileByUsername: function(username) {
|
||||||
|
return this._getProfilesUsernameMap()[username];
|
||||||
|
},
|
||||||
|
getProfilesUsernameMap: function() {
|
||||||
|
return this._getProfilesUsernameMap();
|
||||||
|
},
|
||||||
|
getProfiles: function() {
|
||||||
|
|
||||||
return this._getProfiles()[this.getCurrentId()];
|
return this._getProfiles();
|
||||||
},
|
},
|
||||||
setCurrentUser: function(user) {
|
getActiveOnlyProfiles: function() {
|
||||||
this.setCurrentId(user.id);
|
var active = {};
|
||||||
this.saveProfile(user);
|
var current = this._getProfiles();
|
||||||
},
|
|
||||||
getLastEmail: function() {
|
|
||||||
return BrowserStore.getItem("last_email", '');
|
|
||||||
},
|
|
||||||
setLastEmail: function(email) {
|
|
||||||
BrowserStore.setItem("last_email", email);
|
|
||||||
},
|
|
||||||
removeCurrentUser: function() {
|
|
||||||
this.setCurrentId(null);
|
|
||||||
},
|
|
||||||
hasProfile: function(userId) {
|
|
||||||
return this._getProfiles()[userId] != null;
|
|
||||||
},
|
|
||||||
getProfile: function(userId) {
|
|
||||||
return this._getProfiles()[userId];
|
|
||||||
},
|
|
||||||
getProfileByUsername: function(username) {
|
|
||||||
return this._getProfilesUsernameMap()[username];
|
|
||||||
},
|
|
||||||
getProfilesUsernameMap: function() {
|
|
||||||
return this._getProfilesUsernameMap();
|
|
||||||
},
|
|
||||||
getProfiles: function() {
|
|
||||||
|
|
||||||
return this._getProfiles();
|
for (var key in current) {
|
||||||
},
|
if (current[key].delete_at === 0) {
|
||||||
getActiveOnlyProfiles: function() {
|
active[key] = current[key];
|
||||||
active = {};
|
}
|
||||||
current = this._getProfiles();
|
}
|
||||||
|
|
||||||
for (var key in current) {
|
return active;
|
||||||
if (current[key].delete_at == 0) {
|
},
|
||||||
active[key] = current[key];
|
saveProfile: function(profile) {
|
||||||
}
|
var ps = this._getProfiles();
|
||||||
}
|
ps[profile.id] = profile;
|
||||||
|
this._storeProfiles(ps);
|
||||||
|
},
|
||||||
|
_storeProfiles: function(profiles) {
|
||||||
|
BrowserStore.setItem('profiles', profiles);
|
||||||
|
var profileUsernameMap = {};
|
||||||
|
for (var id in profiles) {
|
||||||
|
profileUsernameMap[profiles[id].username] = profiles[id];
|
||||||
|
}
|
||||||
|
BrowserStore.setItem('profileUsernameMap', profileUsernameMap);
|
||||||
|
},
|
||||||
|
_getProfiles: function() {
|
||||||
|
return BrowserStore.getItem('profiles', {});
|
||||||
|
},
|
||||||
|
_getProfilesUsernameMap: function() {
|
||||||
|
return BrowserStore.getItem('profileUsernameMap', {});
|
||||||
|
},
|
||||||
|
setSessions: function(sessions) {
|
||||||
|
BrowserStore.setItem('sessions', sessions);
|
||||||
|
},
|
||||||
|
getSessions: function() {
|
||||||
|
return BrowserStore.getItem('sessions', {loading: true});
|
||||||
|
},
|
||||||
|
setAudits: function(audits) {
|
||||||
|
BrowserStore.setItem('audits', audits);
|
||||||
|
},
|
||||||
|
getAudits: function() {
|
||||||
|
return BrowserStore.getItem('audits', {loading: true});
|
||||||
|
},
|
||||||
|
setTeams: function(teams) {
|
||||||
|
BrowserStore.setItem('teams', teams);
|
||||||
|
},
|
||||||
|
getTeams: function() {
|
||||||
|
return BrowserStore.getItem('teams', []);
|
||||||
|
},
|
||||||
|
getCurrentMentionKeys: function() {
|
||||||
|
var user = this.getCurrentUser();
|
||||||
|
|
||||||
return active;
|
var keys = [];
|
||||||
},
|
|
||||||
saveProfile: function(profile) {
|
|
||||||
var ps = this._getProfiles();
|
|
||||||
ps[profile.id] = profile;
|
|
||||||
this._storeProfiles(ps);
|
|
||||||
},
|
|
||||||
_storeProfiles: function(profiles) {
|
|
||||||
BrowserStore.setItem("profiles", profiles);
|
|
||||||
var profileUsernameMap = {};
|
|
||||||
for (var id in profiles) {
|
|
||||||
profileUsernameMap[profiles[id].username] = profiles[id];
|
|
||||||
}
|
|
||||||
BrowserStore.setItem("profileUsernameMap", profileUsernameMap);
|
|
||||||
},
|
|
||||||
_getProfiles: function() {
|
|
||||||
return BrowserStore.getItem("profiles", {});
|
|
||||||
},
|
|
||||||
_getProfilesUsernameMap: function() {
|
|
||||||
return BrowserStore.getItem("profileUsernameMap", {});
|
|
||||||
},
|
|
||||||
setSessions: function(sessions) {
|
|
||||||
BrowserStore.setItem("sessions", sessions);
|
|
||||||
},
|
|
||||||
getSessions: function() {
|
|
||||||
return BrowserStore.getItem("sessions", {loading: true});
|
|
||||||
},
|
|
||||||
setAudits: function(audits) {
|
|
||||||
BrowserStore.setItem("audits", audits);
|
|
||||||
},
|
|
||||||
getAudits: function() {
|
|
||||||
return BrowserStore.getItem("audits", {loading: true});
|
|
||||||
},
|
|
||||||
setTeams: function(teams) {
|
|
||||||
BrowserStore.setItem("teams", teams);
|
|
||||||
},
|
|
||||||
getTeams: function() {
|
|
||||||
return BrowserStore.getItem("teams", []);
|
|
||||||
},
|
|
||||||
getCurrentMentionKeys: function() {
|
|
||||||
var user = this.getCurrentUser();
|
|
||||||
|
|
||||||
var keys = [];
|
if (!user || !user.notify_props) {
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.notify_props.mention_keys) {
|
||||||
|
keys = keys.concat(user.notify_props.mention_keys.split(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
if (!user)
|
|
||||||
return keys;
|
return keys;
|
||||||
|
},
|
||||||
if (user.notify_props && user.notify_props.mention_keys) keys = keys.concat(user.notify_props.mention_keys.split(','));
|
getLastVersion: function() {
|
||||||
if (user.first_name && user.notify_props.first_name === "true") keys.push(user.first_name);
|
return BrowserStore.getItem('last_version', '');
|
||||||
if (user.notify_props.all === "true") keys.push('@all');
|
},
|
||||||
if (user.notify_props.channel === "true") keys.push('@channel');
|
setLastVersion: function(version) {
|
||||||
|
BrowserStore.setItem('last_version', version);
|
||||||
return keys;
|
},
|
||||||
},
|
setStatuses: function(statuses) {
|
||||||
getLastVersion: function() {
|
this._setStatuses(statuses);
|
||||||
return BrowserStore.getItem("last_version", '');
|
this.emitStatusesChange();
|
||||||
},
|
},
|
||||||
setLastVersion: function(version) {
|
_setStatuses: function(statuses) {
|
||||||
BrowserStore.setItem("last_version", version);
|
BrowserStore.setItem('statuses', statuses);
|
||||||
},
|
},
|
||||||
setStatuses: function(statuses) {
|
setStatus: function(userId, status) {
|
||||||
this._setStatuses(statuses);
|
var statuses = this.getStatuses();
|
||||||
this.emitStatusesChange();
|
statuses[userId] = status;
|
||||||
},
|
this._setStatuses(statuses);
|
||||||
_setStatuses: function(statuses) {
|
this.emitStatusesChange();
|
||||||
BrowserStore.setItem("statuses", statuses);
|
},
|
||||||
},
|
getStatuses: function() {
|
||||||
setStatus: function(user_id, status) {
|
return BrowserStore.getItem('statuses', {});
|
||||||
var statuses = this.getStatuses();
|
},
|
||||||
statuses[user_id] = status;
|
getStatus: function(id) {
|
||||||
this._setStatuses(statuses);
|
return this.getStatuses()[id];
|
||||||
this.emitStatusesChange();
|
}
|
||||||
},
|
|
||||||
getStatuses: function() {
|
|
||||||
return BrowserStore.getItem("statuses", {});
|
|
||||||
},
|
|
||||||
getStatus: function(id) {
|
|
||||||
return this.getStatuses()[id];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
UserStore.dispatchToken = AppDispatcher.register(function(payload) {
|
UserStore.dispatchToken = AppDispatcher.register(function(payload) {
|
||||||
var action = payload.action;
|
var action = payload.action;
|
||||||
|
|
||||||
switch(action.type) {
|
switch (action.type) {
|
||||||
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()) {
|
||||||
var profile = action.profiles[id];
|
continue;
|
||||||
UserStore.saveProfile(profile);
|
}
|
||||||
UserStore.emitChange(profile.id);
|
var profile = action.profiles[id];
|
||||||
}
|
UserStore.saveProfile(profile);
|
||||||
break;
|
UserStore.emitChange(profile.id);
|
||||||
case ActionTypes.RECIEVED_ME:
|
}
|
||||||
UserStore.setCurrentUser(action.me);
|
break;
|
||||||
UserStore.emitChange(action.me.id);
|
case ActionTypes.RECIEVED_ME:
|
||||||
break;
|
UserStore.setCurrentUser(action.me);
|
||||||
case ActionTypes.RECIEVED_SESSIONS:
|
UserStore.emitChange(action.me.id);
|
||||||
UserStore.setSessions(action.sessions);
|
break;
|
||||||
UserStore.emitSessionsChange();
|
case ActionTypes.RECIEVED_SESSIONS:
|
||||||
break;
|
UserStore.setSessions(action.sessions);
|
||||||
case ActionTypes.RECIEVED_AUDITS:
|
UserStore.emitSessionsChange();
|
||||||
UserStore.setAudits(action.audits);
|
break;
|
||||||
UserStore.emitAuditsChange();
|
case ActionTypes.RECIEVED_AUDITS:
|
||||||
break;
|
UserStore.setAudits(action.audits);
|
||||||
case ActionTypes.RECIEVED_TEAMS:
|
UserStore.emitAuditsChange();
|
||||||
UserStore.setTeams(action.teams);
|
break;
|
||||||
UserStore.emitTeamsChange();
|
case ActionTypes.RECIEVED_TEAMS:
|
||||||
break;
|
UserStore.setTeams(action.teams);
|
||||||
case ActionTypes.RECIEVED_STATUSES:
|
UserStore.emitTeamsChange();
|
||||||
UserStore._setStatuses(action.statuses);
|
break;
|
||||||
UserStore.emitStatusesChange();
|
case ActionTypes.RECIEVED_STATUSES:
|
||||||
break;
|
UserStore._setStatuses(action.statuses);
|
||||||
|
UserStore.emitStatusesChange();
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
UserStore.setMaxListeners(0);
|
UserStore.setMaxListeners(0);
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ module.exports.getMe = function() {
|
|||||||
if (isCallInProgress("getMe")) return;
|
if (isCallInProgress("getMe")) return;
|
||||||
|
|
||||||
callTracker["getMe"] = utils.getTimestamp();
|
callTracker["getMe"] = utils.getTimestamp();
|
||||||
client.getMeSynchronous(
|
client.getMe(
|
||||||
function(data, textStatus, xhr) {
|
function(data, textStatus, xhr) {
|
||||||
callTracker["getMe"] = 0;
|
callTracker["getMe"] = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -279,32 +279,24 @@ module.exports.getAudits = function(userId, success, error) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.getMeSynchronous = function(success, error) {
|
module.exports.getMe = function(success, error) {
|
||||||
|
|
||||||
var current_user = null;
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
async: false,
|
|
||||||
url: "/api/v1/users/me",
|
url: "/api/v1/users/me",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: 'application/json',
|
contentType: 'application/json',
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
success: function(data, textStatus, xhr) {
|
success: success,
|
||||||
current_user = data;
|
|
||||||
if (success) success(data, textStatus, xhr);
|
|
||||||
},
|
|
||||||
error: function(xhr, status, err) {
|
error: function(xhr, status, err) {
|
||||||
var ieChecker = window.navigator.userAgent; // This and the condition below is used to check specifically for browsers IE10 & 11 to suppress a 200 'OK' error from appearing on login
|
var ieChecker = window.navigator.userAgent; // This and the condition below is used to check specifically for browsers IE10 & 11 to suppress a 200 'OK' error from appearing on login
|
||||||
if (xhr.status != 200 || !(ieChecker.indexOf("Trident/7.0") > 0 || ieChecker.indexOf("Trident/6.0") > 0)) {
|
if (xhr.status != 200 || !(ieChecker.indexOf("Trident/7.0") > 0 || ieChecker.indexOf("Trident/6.0") > 0)) {
|
||||||
if (error) {
|
if (error) {
|
||||||
e = handleError("getMeSynchronous", xhr, status, err);
|
e = handleError("getMe", xhr, status, err);
|
||||||
error(e);
|
error(e);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return current_user;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.inviteMembers = function(data, success, error) {
|
module.exports.inviteMembers = function(data, success, error) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user