summaryrefslogtreecommitdiffstats
path: root/web/react
diff options
context:
space:
mode:
Diffstat (limited to 'web/react')
-rw-r--r--web/react/components/mention_list.jsx17
-rw-r--r--web/react/components/new_channel.jsx2
-rw-r--r--web/react/components/post_list.jsx4
-rw-r--r--web/react/components/settings_sidebar.jsx3
-rw-r--r--web/react/components/sidebar.jsx217
-rw-r--r--web/react/components/sidebar_header.jsx4
-rw-r--r--web/react/components/sidebar_right_menu.jsx75
-rw-r--r--web/react/components/textbox.jsx161
-rw-r--r--web/react/components/user_settings.jsx133
-rw-r--r--web/react/stores/post_store.jsx354
-rw-r--r--web/react/stores/user_store.jsx447
-rw-r--r--web/react/utils/async_client.jsx2
-rw-r--r--web/react/utils/client.jsx14
13 files changed, 722 insertions, 711 deletions
diff --git a/web/react/components/mention_list.jsx b/web/react/components/mention_list.jsx
index 5f1bb6d0e..f562cfb29 100644
--- a/web/react/components/mention_list.jsx
+++ b/web/react/components/mention_list.jsx
@@ -81,7 +81,7 @@ module.exports = React.createClass({
this.setState({selectedMention: 0, selectedUsername: ''});
}
},
- onListenerChange: function(id, mentionText, excludeList) {
+ onListenerChange: function(id, mentionText) {
if (id !== this.props.id) {
return;
}
@@ -90,9 +90,6 @@ module.exports = React.createClass({
if (mentionText != null) {
newState.mentionText = mentionText;
}
- if (excludeList != null) {
- newState.excludeUsers = excludeList;
- }
this.setState(newState);
},
@@ -149,15 +146,6 @@ module.exports = React.createClass({
scrollTop: scrollAmount
}, 75);
},
- alreadyMentioned: function(username) {
- var excludeUsers = this.state.excludeUsers;
- for (var i = 0; i < excludeUsers.length; i++) {
- if (excludeUsers[i] === username) {
- return true;
- }
- }
- return false;
- },
getInitialState: function() {
return {excludeUsers: [], mentionText: '-1', selectedMention: 0, selectedUsername: ''};
},
@@ -201,9 +189,6 @@ module.exports = React.createClass({
var index = 0;
for (var i = 0; i < users.length && index < MAX_ITEMS_IN_LIST; i++) {
- if (this.alreadyMentioned(users[i].username)) {
- continue;
- }
if ((users[i].first_name && users[i].first_name.lastIndexOf(mentionText, 0) === 0) ||
(users[i].last_name && users[i].last_name.lastIndexOf(mentionText, 0) === 0) ||
users[i].username.lastIndexOf(mentionText, 0) === 0) {
diff --git a/web/react/components/new_channel.jsx b/web/react/components/new_channel.jsx
index ffcbfd32d..c22147022 100644
--- a/web/react/components/new_channel.jsx
+++ b/web/react/components/new_channel.jsx
@@ -143,7 +143,7 @@ module.exports = React.createClass({
</div>
<div className='modal-footer'>
<button type='button' className='btn btn-default' data-dismiss='modal'>Cancel</button>
- <button onClick={this.handleSubmit} type='submit' className='btn btn-primary'>Create New Channel</button>
+ <button onClick={this.handleSubmit} type='submit' className='btn btn-primary'>Create New {channelTerm}</button>
</div>
</form>
</div>
diff --git a/web/react/components/post_list.jsx b/web/react/components/post_list.jsx
index bb1b1704c..83f806b79 100644
--- a/web/react/components/post_list.jsx
+++ b/web/react/components/post_list.jsx
@@ -439,7 +439,7 @@ module.exports = React.createClass({
currentPostDay = utils.getDateForUnixTicks(post.create_at);
if (currentPostDay.toDateString() != previousPostDay.toDateString()) {
postCtls.push(
- <div className="date-separator">
+ <div key={currentPostDay.toDateString()} className="date-separator">
<hr className="separator__hr" />
<div className="separator__text">{currentPostDay.toDateString()}</div>
</div>
@@ -449,7 +449,7 @@ module.exports = React.createClass({
if (post.create_at > last_viewed && !rendered_last_viewed) {
rendered_last_viewed = true;
postCtls.push(
- <div className="new-separator">
+ <div key="unviewed" className="new-separator">
<hr id="new_message" className="separator__hr" />
<div className="separator__text">New Messages</div>
</div>
diff --git a/web/react/components/settings_sidebar.jsx b/web/react/components/settings_sidebar.jsx
index ae8510cf2..b4d291622 100644
--- a/web/react/components/settings_sidebar.jsx
+++ b/web/react/components/settings_sidebar.jsx
@@ -4,6 +4,7 @@
var utils = require('../utils/utils.jsx');
module.exports = React.createClass({
+ displayName:'SettingsSidebar',
updateTab: function(tab) {
this.props.updateTab(tab);
$('.settings-modal').addClass('display--content');
@@ -14,7 +15,7 @@ module.exports = React.createClass({
<div className="">
<ul className="nav nav-pills nav-stacked">
{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>
</div>
diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx
index 1d39f5f67..fe73cbcf7 100644
--- a/web/react/components/sidebar.jsx
+++ b/web/react/components/sidebar.jsx
@@ -56,7 +56,6 @@ function getStateFromStores() {
var channelMember = members[channel.id];
var msgCount = channel.total_msg_count - channelMember.msg_count;
if (msgCount > 0) {
- channel.unread = msgCount;
showDirectChannels.push(channel);
} else if (currentId === channel.id) {
showDirectChannels.push(channel);
@@ -70,6 +69,7 @@ function getStateFromStores() {
tempChannel.display_name = utils.getDisplayName(teammate);
tempChannel.status = UserStore.getStatus(teammate.id);
tempChannel.last_post_at = 0;
+ tempChannel.total_msg_count = 0;
readDirectChannels.push(tempChannel);
}
}
@@ -132,11 +132,17 @@ module.exports = React.createClass({
$('.nav-pills__container').perfectScrollbar();
this.updateTitle();
+ this.updateUnreadIndicators();
+
+ $(window).on('resize', this.onResize);
},
componentDidUpdate: function() {
this.updateTitle();
+ this.updateUnreadIndicators();
},
componentWillUnmount: function() {
+ $(window).off('resize', this.onResize);
+
ChannelStore.removeChangeListener(this.onChange);
UserStore.removeChangeListener(this.onChange);
UserStore.removeStatusesChangeListener(this.onChange);
@@ -157,7 +163,10 @@ module.exports = React.createClass({
}
if (UserStore.getCurrentId() !== msg.user_id) {
- var mentions = msg.props.mentions ? JSON.parse(msg.props.mentions) : [];
+ var mentions = [];
+ if (msg.props.mentions) {
+ mentions = JSON.parse(msg.props.mentions);
+ }
var channel = ChannelStore.get(msg.channel_id);
var user = UserStore.getCurrentUser();
@@ -175,7 +184,10 @@ module.exports = React.createClass({
username = UserStore.getProfile(msg.user_id).username;
}
- var title = channel ? channel.display_name : 'Posted';
+ var title = 'Posted';
+ if (channel) {
+ title = channel.display_name;
+ }
var repRegex = new RegExp('<br>', 'g');
var post = JSON.parse(msg.props.post);
@@ -235,103 +247,143 @@ module.exports = React.createClass({
}
}
},
+ onScroll: function(e) {
+ this.updateUnreadIndicators();
+ },
+ onResize: function(e) {
+ this.updateUnreadIndicators();
+ },
+ updateUnreadIndicators: function() {
+ var container = $(this.refs.container.getDOMNode());
+
+ if (this.firstUnreadChannel) {
+ var firstUnreadElement = $(this.refs[this.firstUnreadChannel].getDOMNode());
+
+ if (firstUnreadElement.position().top + firstUnreadElement.height() < 0) {
+ $(this.refs.topUnreadIndicator.getDOMNode()).css('display', 'initial');
+ } else {
+ $(this.refs.topUnreadIndicator.getDOMNode()).css('display', 'none');
+ }
+ }
+
+ if (this.lastUnreadChannel) {
+ var lastUnreadElement = $(this.refs[this.lastUnreadChannel].getDOMNode());
+
+ if (lastUnreadElement.position().top > container.height()) {
+ $(this.refs.bottomUnreadIndicator.getDOMNode()).css('bottom', '0');
+ $(this.refs.bottomUnreadIndicator.getDOMNode()).css('display', 'initial');
+ } else {
+ $(this.refs.bottomUnreadIndicator.getDOMNode()).css('display', 'none');
+ }
+ }
+ },
getInitialState: function() {
return getStateFromStores();
},
render: function() {
var members = this.state.members;
- var newsActive = window.location.pathname === '/' ? 'active' : '';
+ var activeId = this.state.active_id;
var badgesActive = false;
+
+ // keep track of the first and last unread channels so we can use them to set the unread indicators
var self = this;
- var channelItems = this.state.channels.map(function(channel) {
- if (channel.type != 'O') {
- return '';
- }
+ this.firstUnreadChannel = null;
+ this.lastUnreadChannel = null;
+ function createChannelElement(channel) {
var channelMember = members[channel.id];
- var active = channel.id === self.state.active_id ? 'active' : '';
- var msgCount = channel.total_msg_count - channelMember.msg_count;
- var titleClass = '';
- if (msgCount > 0 && channelMember.notify_level !== 'quiet') {
- titleClass = 'unread-title';
+ var linkClass = '';
+ if (channel.id === self.state.active_id) {
+ linkClass = 'active';
}
- var badge = '';
- if (channelMember.mention_count > 0) {
- badge = <span className='badge pull-right small'>{channelMember.mention_count}</span>;
- badgesActive = true;
- titleClass = 'unread-title';
+ var unread = false;
+ if (channelMember) {
+ var msgCount = channel.total_msg_count - channelMember.msg_count;
+ unread = (msgCount > 0 && channelMember.notify_level !== 'quiet') || channelMember.mention_count > 0;
}
- return (
- <li key={channel.id} className={active}><a className={'sidebar-channel ' + titleClass} href='#' onClick={function(e){e.preventDefault(); utils.switchChannel(channel);}}>{badge}{channel.display_name}</a></li>
- );
- });
+ var titleClass = '';
+ if (unread) {
+ titleClass = 'unread-title';
- var privateChannelItems = this.state.channels.map(function(channel) {
- if (channel.type !== 'P') {
- return '';
+ if (!self.firstUnreadChannel) {
+ self.firstUnreadChannel = channel.name;
+ }
+ self.lastUnreadChannel = channel.name;
}
- var channelMember = members[channel.id];
- var active = channel.id === self.state.active_id ? 'active' : '';
+ var badge = null;
+ if (channelMember) {
+ if (channel.type === 'D') {
+ // direct message channels show badges for any number of unread posts
+ var msgCount = channel.total_msg_count - channelMember.msg_count;
+ if (msgCount > 0) {
+ badge = <span className='badge pull-right small'>{msgCount}</span>;
+ badgesActive = true;
+ }
+ } else if (channelMember.mention_count > 0) {
+ // public and private channels only show badges for mentions
+ badge = <span className='badge pull-right small'>{channelMember.mention_count}</span>;
+ badgesActive = true;
+ }
+ }
- var msgCount = channel.total_msg_count - channelMember.msg_count;
- var titleClass = ''
- if (msgCount > 0 && channelMember.notify_level !== 'quiet') {
- titleClass = 'unread-title'
+ // set up status icon for direct message channels
+ var status = null;
+ if (channel.type === 'D') {
+ var statusIcon = '';
+ if (channel.status === 'online') {
+ statusIcon = Constants.ONLINE_ICON_SVG;
+ } else if (channel.status === 'away') {
+ statusIcon = Constants.ONLINE_ICON_SVG;
+ } else {
+ statusIcon = Constants.OFFLINE_ICON_SVG;
+ }
+ status = <span className='status' dangerouslySetInnerHTML={{__html: statusIcon}} />;
}
- var badge = '';
- if (channelMember.mention_count > 0) {
- badge = <span className='badge pull-right small'>{channelMember.mention_count}</span>;
- badgesActive = true;
- titleClass = 'unread-title';
+ // set up click handler to switch channels (or create a new channel for non-existant ones)
+ var clickHandler = null;
+ var href;
+ if (!channel.fake) {
+ clickHandler = function(e) {
+ e.preventDefault();
+ utils.switchChannel(channel);
+ };
+ href = '#';
+ } else {
+ href = TeamStore.getCurrentTeamUrl() + '/channels/' + channel.name;
}
return (
- <li key={channel.id} className={active}><a className={'sidebar-channel ' + titleClass} href='#' onClick={function(e){e.preventDefault(); utils.switchChannel(channel);}}>{badge}{channel.display_name}</a></li>
+ <li key={channel.name} ref={channel.name} className={linkClass}>
+ <a className={'sidebar-channel ' + titleClass} href={href} onClick={clickHandler}>
+ {status}
+ {badge}
+ {channel.display_name}
+ </a>
+ </li>
);
- });
-
- var directMessageItems = this.state.showDirectChannels.map(function(channel) {
- var badge = '';
- var titleClass = '';
+ };
- var statusIcon = '';
- if (channel.status === 'online') {
- statusIcon = Constants.ONLINE_ICON_SVG;
- } else if (channel.status === 'away') {
- statusIcon = Constants.ONLINE_ICON_SVG;
- } else {
- statusIcon = Constants.OFFLINE_ICON_SVG;
+ // create elements for all 3 types of channels
+ var channelItems = this.state.channels.filter(
+ function(channel) {
+ return channel.type === 'O';
}
+ ).map(createChannelElement);
- if (!channel.fake) {
- var active = channel.id === self.state.active_id ? 'active' : '';
-
- if (channel.unread) {
- badge = <span className='badge pull-right small'>{channel.unread}</span>;
- badgesActive = true;
- titleClass = 'unread-title';
- }
-
- function handleClick(e) {
- e.preventDefault();
- utils.switchChannel(channel, channel.teammate_username);
- }
-
- return (
- <li key={channel.name} className={active}><a className={'sidebar-channel ' + titleClass} href='#' onClick={handleClick}><span className='status' dangerouslySetInnerHTML={{__html: statusIcon}} /> {badge}{channel.display_name}</a></li>
- );
- } else {
- return (
- <li key={channel.name} className={active}><a className={'sidebar-channel ' + titleClass} href={TeamStore.getCurrentTeamUrl() + '/channels/' + channel.name}><span className='status' dangerouslySetInnerHTML={{__html: statusIcon}} /> {badge}{channel.display_name}</a></li>
- );
+ var privateChannelItems = this.state.channels.filter(
+ function(channel) {
+ return channel.type === 'P';
}
- });
+ ).map(createChannelElement);
+
+ var directMessageItems = this.state.showDirectChannels.map(createChannelElement);
+ // update the favicon to show if there are any notifications
var link = document.createElement('link');
link.type = 'image/x-icon';
link.rel = 'shortcut icon';
@@ -348,19 +400,26 @@ module.exports = React.createClass({
}
head.appendChild(link);
- if (channelItems.length == 0) {
- <li><small>Loading...</small></li>
+ var directMessageMore = null;
+ if (this.state.hideDirectChannels.length > 0) {
+ directMessageMore = (
+ <li>
+ <a href='#' data-toggle='modal' className='nav-more' data-target='#more_direct_channels' data-channels={JSON.stringify(this.state.hideDirectChannels)}>
+ {'More ('+this.state.hideDirectChannels.length+')'}
+ </a>
+ </li>
+ );
}
- if (privateChannelItems.length == 0) {
- <li><small>Loading...</small></li>
- }
return (
<div>
<SidebarHeader teamDisplayName={this.props.teamDisplayName} teamType={this.props.teamType} />
<SearchBox />
- <div className='nav-pills__container'>
+ <div ref='topUnreadIndicator' className='nav-pills__unread-indicator nav-pills__unread-indicator-top' style={{display: 'none'}}>Unread post(s) above</div>
+ <div ref='bottomUnreadIndicator' className='nav-pills__unread-indicator nav-pills__unread-indicator-bottom' style={{display: 'none'}}>Unread post(s) below</div>
+
+ <div ref='container' className='nav-pills__container' onScroll={this.onScroll}>
<ul className='nav nav-pills nav-stacked'>
<li><h4>Channels<a className='add-channel-btn' href='#' data-toggle='modal' data-target='#new_channel' data-channeltype='O'>+</a></h4></li>
{channelItems}
@@ -374,9 +433,7 @@ module.exports = React.createClass({
<ul className='nav nav-pills nav-stacked'>
<li><h4>Private Messages</h4></li>
{directMessageItems}
- { this.state.hideDirectChannels.length > 0 ?
- <li><a href='#' data-toggle='modal' className='nav-more' data-target='#more_direct_channels' data-channels={JSON.stringify(this.state.hideDirectChannels)}>{'More ('+this.state.hideDirectChannels.length+')'}</a></li>
- : '' }
+ {directMessageMore}
</ul>
</div>
</div>
diff --git a/web/react/components/sidebar_header.jsx b/web/react/components/sidebar_header.jsx
index ba8f9bacd..cc3f255ee 100644
--- a/web/react/components/sidebar_header.jsx
+++ b/web/react/components/sidebar_header.jsx
@@ -64,7 +64,7 @@ var NavbarDropdown = React.createClass({
if (this.props.teamType === 'O') {
teamLink = (
<li>
- <a href='#' data-toggle='modal' data-target='#get_link' data-title='Team Invite' data-value={location.origin + '/signup_user_complete/?id=' + currentUser.team_id}>Get Team Invite Link</a>
+ <a href='#' data-toggle='modal' data-target='#get_link' data-title='Team Invite' data-value={utils.getWindowLocationOrigin() + '/signup_user_complete/?id=' + currentUser.team_id}>Get Team Invite Link</a>
</li>
);
}
@@ -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 (
<ul className='nav navbar-nav navbar-right'>
diff --git a/web/react/components/sidebar_right_menu.jsx b/web/react/components/sidebar_right_menu.jsx
index 15306a499..2439719a1 100644
--- a/web/react/components/sidebar_right_menu.jsx
+++ b/web/react/components/sidebar_right_menu.jsx
@@ -3,6 +3,7 @@
var UserStore = require('../stores/user_store.jsx');
var client = require('../utils/client.jsx');
+var utils = require('../utils/utils.jsx');
module.exports = React.createClass({
handleLogoutClick: function(e) {
@@ -10,65 +11,77 @@ module.exports = React.createClass({
client.logout();
},
render: function() {
- var team_link = "";
- var invite_link = "";
- var manage_link = "";
- var rename_link = "";
- var currentUser = UserStore.getCurrentUser()
+ var teamLink = '';
+ var inviteLink = '';
+ var teamSettingsLink = '';
+ var manageLink = '';
+ var renameLink = '';
+ var currentUser = UserStore.getCurrentUser();
var isAdmin = false;
if (currentUser != null) {
- isAdmin = currentUser.roles.indexOf("admin") > -1;
+ isAdmin = currentUser.roles.indexOf('admin') > -1;
- invite_link = (
+ inviteLink = (
<li>
- <a href="#" data-toggle="modal" data-target="#invite_member"><i className="glyphicon glyphicon-user"></i>Invite New Member</a>
+ <a href='#' data-toggle='modal' data-target='#invite_member'><i className='glyphicon glyphicon-user'></i>Invite New Member</a>
</li>
);
- if (this.props.teamType == "O") {
- team_link = (
+ if (this.props.teamType === 'O') {
+ teamLink = (
<li>
- <a href="#" data-toggle="modal" data-target="#get_link" data-title="Team Invite" data-value={location.origin+"/signup_user_complete/?id="+currentUser.team_id}><i className="glyphicon glyphicon-link"></i>Get Team Invite Link</a>
+ <a href='#' data-toggle='modal' data-target='#get_link' data-title='Team Invite' data-value={utils.getWindowLocationOrigin()+'/signup_user_complete/?id='+currentUser.team_id}><i className='glyphicon glyphicon-link'></i>Get Team Invite Link</a>
</li>
);
}
}
if (isAdmin) {
- manage_link = (
+ teamSettingsLink = (
<li>
- <a href="#" data-toggle="modal" data-target="#team_members"><i className="glyphicon glyphicon-wrench"></i>Manage Team</a>
+ <a href='#' data-toggle='modal' data-target='#team_settings'><i className='glyphicon glyphicon-globe'></i>Team Settings</a>
</li>
);
- rename_link = (
+ manageLink = (
<li>
- <a href="#" data-toggle="modal" data-target="#rename_team_link"><i className="glyphicon glyphicon-pencil"></i>Rename</a>
+ <a href='#' data-toggle='modal' data-target='#team_members'><i className='glyphicon glyphicon-wrench'></i>Manage Team</a>
+ </li>
+ );
+ renameLink = (
+ <li>
+ <a href='#' data-toggle='modal' data-target='#rename_team_link'><i className='glyphicon glyphicon-pencil'></i>Rename</a>
</li>
);
}
- var siteName = config.SiteName != null ? config.SiteName : "";
- var teamDisplayName = this.props.teamDisplayName ? this.props.teamDisplayName : siteName;
+ var siteName = '';
+ if (config.SiteName != null) {
+ siteName = config.SiteName;
+ }
+ var teamDisplayName = siteName;
+ if (this.props.teamDisplayName) {
+ teamDisplayName = this.props.teamDisplayName;
+ }
return (
<div>
- <div className="team__header theme">
- <a className="team__name" href="/channels/town-square">{ teamDisplayName }</a>
+ <div className='team__header theme'>
+ <a className='team__name' href='/channels/town-square'>{teamDisplayName}</a>
</div>
- <div className="nav-pills__container">
- <ul className="nav nav-pills nav-stacked">
- <li><a href="#" data-toggle="modal" data-target="#user_settings1"><i className="glyphicon glyphicon-cog"></i>Account Settings</a></li>
- { isAdmin ? <li><a href="#" data-toggle="modal" data-target="#team_settings"><i className="glyphicon glyphicon-globe"></i>Team Settings</a></li> : "" }
- { invite_link }
- { team_link }
- { manage_link }
- { rename_link }
- <li><a href="#" onClick={this.handleLogoutClick}><i className="glyphicon glyphicon-log-out"></i>Logout</a></li>
- <li className="divider"></li>
- <li><a target="_blank" href="/static/help/configure_links.html"><i className="glyphicon glyphicon-question-sign"></i>Help</a></li>
- <li><a target="_blank" href="/static/help/configure_links.html"><i className="glyphicon glyphicon-earphone"></i>Report a Problem</a></li>
+ <div className='nav-pills__container'>
+ <ul className='nav nav-pills nav-stacked'>
+ <li><a href='#' data-toggle='modal' data-target='#user_settings1'><i className='glyphicon glyphicon-cog'></i>Account Settings</a></li>
+ {teamSettingsLink}
+ {inviteLink}
+ {teamLink}
+ {manageLink}
+ {renameLink}
+ <li><a href='#' onClick={this.handleLogoutClick}><i className='glyphicon glyphicon-log-out'></i>Logout</a></li>
+ <li className='divider'></li>
+ <li><a target='_blank' href='/static/help/configure_links.html'><i className='glyphicon glyphicon-question-sign'></i>Help</a></li>
+ <li><a target='_blank' href='/static/help/configure_links.html'><i className='glyphicon glyphicon-earphone'></i>Report a Problem</a></li>
</ul>
</div>
</div>
diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx
index bbd1f84b6..b5c5cc564 100644
--- a/web/react/components/textbox.jsx
+++ b/web/react/components/textbox.jsx
@@ -2,11 +2,7 @@
// See License.txt for license information.
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
-var UserStore = require('../stores/user_store.jsx');
var PostStore = require('../stores/post_store.jsx');
-var SocketStore = require('../stores/socket_store.jsx');
-var MsgTyping = require('./msg_typing.jsx');
-var MentionList = require('./mention_list.jsx');
var CommandList = require('./command_list.jsx');
var ErrorStore = require('../stores/error_store.jsx');
var AsyncClient = require('../utils/async_client.jsx');
@@ -19,53 +15,53 @@ function getStateFromStores() {
var error = ErrorStore.getLastError();
if (error) {
- return { message: error.message };
- } else {
- return { message: null };
+ return {message: error.message};
}
+ return {message: null};
}
module.exports = React.createClass({
+ displayName: 'Textbox',
caret: -1,
addedMention: false,
doProcessMentions: false,
mentions: [],
componentDidMount: function() {
- PostStore.addAddMentionListener(this._onChange);
- ErrorStore.addChangeListener(this._onError);
+ PostStore.addAddMentionListener(this.onListenerChange);
+ ErrorStore.addChangeListener(this.onRecievedError);
this.resize();
- this.processMentions();
+ this.updateMentionTab(null);
},
componentWillUnmount: function() {
- PostStore.removeAddMentionListener(this._onChange);
- ErrorStore.removeChangeListener(this._onError);
+ PostStore.removeAddMentionListener(this.onListenerChange);
+ ErrorStore.removeChangeListener(this.onRecievedError);
},
- _onChange: function(id, username) {
- if (id !== this.props.id) return;
- this.addMention(username);
+ onListenerChange: function(id, username) {
+ if (id === this.props.id) {
+ this.addMention(username);
+ }
},
- _onError: function() {
+ onRecievedError: function() {
var errorState = getStateFromStores();
if (this.state.timerInterrupt != null) {
window.clearInterval(this.state.timerInterrupt);
- this.setState({ timerInterrupt: null });
+ this.setState({timerInterrupt: null});
}
- if (errorState.message === "There appears to be a problem with your internet connection") {
- this.setState({ connection: "bad-connection" });
- var timerInterrupt = window.setInterval(this._onTimerInterrupt, 5000);
- this.setState({ timerInterrupt: timerInterrupt });
- }
- else {
- this.setState({ connection: "" });
+ if (errorState.message === 'There appears to be a problem with your internet connection') {
+ this.setState({connection: 'bad-connection'});
+ var timerInterrupt = window.setInterval(this.onTimerInterrupt, 5000);
+ this.setState({timerInterrupt: timerInterrupt});
+ } else {
+ this.setState({connection: ''});
}
},
- _onTimerInterrupt: function() {
+ onTimerInterrupt: function() {
//Since these should only happen when you have no connection and slightly briefly after any
//performance hit should not matter
- if (this.state.connection === "bad-connection") {
+ if (this.state.connection === 'bad-connection') {
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_ERROR,
err: null
@@ -75,15 +71,15 @@ module.exports = React.createClass({
}
window.clearInterval(this.state.timerInterrupt);
- this.setState({ timerInterrupt: null });
+ this.setState({timerInterrupt: null});
},
componentDidUpdate: function() {
if (this.caret >= 0) {
- utils.setCaretPosition(this.refs.message.getDOMNode(), this.caret)
+ utils.setCaretPosition(this.refs.message.getDOMNode(), this.caret);
this.caret = -1;
}
if (this.doProcessMentions) {
- this.processMentions();
+ this.updateMentionTab(null);
this.doProcessMentions = false;
}
this.resize();
@@ -93,7 +89,7 @@ module.exports = React.createClass({
this.checkForNewMention(nextProps.messageText);
}
var text = this.refs.message.getDOMNode().value;
- if (nextProps.channelId != this.props.channelId || nextProps.messageText !== text) {
+ if (nextProps.channelId !== this.props.channelId || nextProps.messageText !== text) {
this.doProcessMentions = true;
}
this.addedMention = false;
@@ -101,17 +97,17 @@ module.exports = React.createClass({
this.resize();
},
getInitialState: function() {
- return { mentionText: '-1', mentions: [], connection: "", timerInterrupt: null };
+ return {mentionText: '-1', mentions: [], connection: '', timerInterrupt: null};
},
- updateMentionTab: function(mentionText, excludeList) {
+ updateMentionTab: function(mentionText) {
var self = this;
+
// using setTimeout so dispatch isn't called during an in progress dispatch
setTimeout(function() {
AppDispatcher.handleViewAction({
type: ActionTypes.RECIEVED_MENTION_DATA,
id: self.props.id,
- mention_text: mentionText,
- exclude_list: excludeList
+ mention_text: mentionText
});
}, 1);
},
@@ -122,13 +118,13 @@ module.exports = React.createClass({
handleKeyPress: function(e) {
var text = this.refs.message.getDOMNode().value;
- if (!this.refs.commands.isEmpty() && text.indexOf("/") == 0 && e.which==13) {
+ if (!this.refs.commands.isEmpty() && text.indexOf('/') === 0 && e.which === 13) {
this.refs.commands.addFirstCommand();
e.preventDefault();
return;
}
- if ( !this.doProcessMentions) {
+ if (!this.doProcessMentions) {
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
var preText = text.substring(0, caret);
var lastSpace = preText.lastIndexOf(' ');
@@ -150,13 +146,15 @@ module.exports = React.createClass({
this.handleBackspace(e);
}
},
- handleBackspace: function(e) {
+ handleBackspace: function() {
var text = this.refs.message.getDOMNode().value;
- if (text.indexOf("/") == 0) {
- this.refs.commands.getSuggestedCommands(text.substring(0, text.length-1));
+ if (text.indexOf('/') === 0) {
+ this.refs.commands.getSuggestedCommands(text.substring(0, text.length - 1));
}
- if (this.doProcessMentions) return;
+ if (this.doProcessMentions) {
+ return;
+ }
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
var preText = text.substring(0, caret);
@@ -167,57 +165,6 @@ module.exports = React.createClass({
this.doProcessMentions = true;
}
},
- processMentions: function() {
- /* First, find all the possible mentions and add
- them all to a list of mentions */
- var text = utils.insertHtmlEntities(this.refs.message.getDOMNode().value);
-
- var profileMap = UserStore.getProfilesUsernameMap();
-
- var re1 = /@([a-z0-9_]+)( |$|\n)/gi;
-
- var matches = text.match(re1);
-
- if (!matches) {
- this.updateMentionTab(null, []);
- return;
- }
-
- var mentions = [];
- for (var i = 0; i < matches.length; i++) {
- var m = matches[i].substring(1,matches[i].length).trim();
- if ((m in profileMap && mentions.indexOf(m) === -1) || Constants.SPECIAL_MENTIONS.indexOf(m) !== -1) {
- mentions.push(m);
- }
- }
-
- /* Figure out what the user is currently typing. If it's a mention then we don't
- want to add it to the mention list yet, so we remove it if
- there is only one occurence of that mention so far. */
- var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
-
- var text = this.props.messageText;
-
- var preText = text.substring(0, caret);
-
- var atIndex = preText.lastIndexOf('@');
- var spaceIndex = preText.lastIndexOf(' ');
- var newLineIndex = preText.lastIndexOf('\n');
-
- var typingMention = "";
- if (atIndex > spaceIndex && atIndex > newLineIndex) {
-
- typingMention = text.substring(atIndex+1, caret);
- }
-
- var re2 = new RegExp('@' + typingMention + '( |$|\n)', 'g');
-
- if ((text.match(re2) || []).length === 1 && mentions.indexOf(typingMention) !== -1) {
- mentions.splice(mentions.indexOf(typingMention), 1);
- }
-
- this.updateMentionTab(null, mentions);
- },
checkForNewMention: function(text) {
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
@@ -227,7 +174,7 @@ module.exports = React.createClass({
// The @ character not typed, so nothing to do.
if (atIndex === -1) {
- this.updateMentionTab('-1', null);
+ this.updateMentionTab('-1');
return;
}
@@ -236,13 +183,13 @@ module.exports = React.createClass({
// If there is a space after the last @, nothing to do.
if (lastSpace > atIndex || lastCharSpace > atIndex) {
- this.updateMentionTab('-1', null);
+ this.updateMentionTab('-1');
return;
}
// Get the name typed so far.
- var name = preText.substring(atIndex+1, preText.length).toLowerCase();
- this.updateMentionTab(name, null);
+ var name = preText.substring(atIndex + 1, preText.length).toLowerCase();
+ this.updateMentionTab(name);
},
addMention: function(name) {
var caret = utils.getCaretPosition(this.refs.message.getDOMNode());
@@ -264,7 +211,7 @@ module.exports = React.createClass({
this.addedMention = true;
this.doProcessMentions = true;
- this.props.onUserInput(prefix + "@" + name + " " + suffix);
+ this.props.onUserInput(prefix + '@' + name + ' ' + suffix);
},
addCommand: function(cmd) {
var elm = this.refs.message.getDOMNode();
@@ -275,22 +222,26 @@ module.exports = React.createClass({
var e = this.refs.message.getDOMNode();
var w = this.refs.wrapper.getDOMNode();
- var lht = parseInt($(e).css('lineHeight'),10);
+ var lht = parseInt($(e).css('lineHeight'), 10);
var lines = e.scrollHeight / lht;
- var mod = lines < 2.5 || this.props.messageText === "" ? 30 : 15;
+ var mod = 15;
+
+ if (lines < 2.5 || this.props.messageText === '') {
+ mod = 30;
+ }
if (e.scrollHeight - mod < 167) {
- $(e).css({'height':'auto','overflow-y':'hidden'}).height(e.scrollHeight - mod);
- $(w).css({'height':'auto'}).height(e.scrollHeight+2);
+ $(e).css({height: 'auto', 'overflow-y': 'hidden'}).height(e.scrollHeight - mod);
+ $(w).css({height: 'auto'}).height(e.scrollHeight + 2);
} else {
- $(e).css({'height':'auto','overflow-y':'scroll'}).height(167);
- $(w).css({'height':'auto'}).height(167);
+ $(e).css({height: 'auto', 'overflow-y': 'scroll'}).height(167);
+ $(w).css({height: 'auto'}).height(167);
}
},
handleFocus: function() {
var elm = this.refs.message.getDOMNode();
if (elm.title === elm.value) {
- elm.value = "";
+ elm.value = '';
}
},
handleBlur: function() {
@@ -304,9 +255,9 @@ module.exports = React.createClass({
},
render: function() {
return (
- <div ref="wrapper" className="textarea-wrapper">
+ <div ref='wrapper' className='textarea-wrapper'>
<CommandList ref='commands' addCommand={this.addCommand} channelId={this.props.channelId} />
- <textarea id={this.props.id} ref="message" className={"form-control custom-textarea " + this.state.connection} spellCheck="true" autoComplete="off" autoCorrect="off" rows="1" placeholder={this.props.createMessage} value={this.props.messageText} onInput={this.handleChange} onChange={this.handleChange} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} onFocus={this.handleFocus} onBlur={this.handleBlur} onPaste={this.handlePaste} />
+ <textarea id={this.props.id} ref='message' className={'form-control custom-textarea ' + this.state.connection} spellCheck='true' autoComplete='off' autoCorrect='off' rows='1' placeholder={this.props.createMessage} value={this.props.messageText} onInput={this.handleChange} onChange={this.handleChange} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} onFocus={this.handleFocus} onBlur={this.handleBlur} onPaste={this.handlePaste} />
</div>
);
}
diff --git a/web/react/components/user_settings.jsx b/web/react/components/user_settings.jsx
index e224f2a87..1a0c313d3 100644
--- a/web/react/components/user_settings.jsx
+++ b/web/react/components/user_settings.jsx
@@ -461,22 +461,22 @@ var SecurityTab = React.createClass({
e.preventDefault();
var user = this.props.user;
- var currentPassword = this.state.current_password;
- var newPassword = this.state.new_password;
- var confirmPassword = this.state.confirm_password;
+ var currentPassword = this.state.currentPassword;
+ var newPassword = this.state.newPassword;
+ var confirmPassword = this.state.confirmPassword;
if (currentPassword === '') {
- this.setState({password_error: 'Please enter your current password', server_error: ''});
+ this.setState({passwordError: 'Please enter your current password', serverError: ''});
return;
}
if (newPassword.length < 5) {
- this.setState({password_error: 'New passwords must be at least 5 characters', server_error: ''});
+ this.setState({passwordError: 'New passwords must be at least 5 characters', serverError: ''});
return;
}
if (newPassword !== confirmPassword) {
- this.setState({password_error: 'The new passwords you entered do not match', server_error: ''});
+ this.setState({passwordError: 'The new passwords you entered do not match', serverError: ''});
return;
}
@@ -486,43 +486,43 @@ var SecurityTab = React.createClass({
data.new_password = newPassword;
client.updatePassword(data,
- function(data) {
- this.props.updateSection("");
+ function() {
+ this.props.updateSection('');
AsyncClient.getMe();
- this.setState({current_password: '', new_password: '', confirm_password: ''});
+ this.setState({currentPassword: '', newPassword: '', confirmPassword: ''});
}.bind(this),
function(err) {
var state = this.getInitialState();
if (err.message) {
- state.server_error = err.message;
+ state.serverError = err.message;
} else {
- state.server_error = err;
+ state.serverError = err;
}
- state.password_error = '';
+ state.passwordError = '';
this.setState(state);
}.bind(this)
);
},
updateCurrentPassword: function(e) {
- this.setState({ current_password: e.target.value });
+ this.setState({currentPassword: e.target.value});
},
updateNewPassword: function(e) {
- this.setState({ new_password: e.target.value });
+ this.setState({newPassword: e.target.value});
},
updateConfirmPassword: function(e) {
- this.setState({ confirm_password: e.target.value });
+ this.setState({confirmPassword: e.target.value});
},
handleHistoryOpen: function() {
- $("#user_settings1").modal('hide');
+ $('#user_settings1').modal('hide');
},
handleDevicesOpen: function() {
- $("#user_settings1").modal('hide');
+ $('#user_settings1').modal('hide');
},
handleClose: function() {
- $(this.getDOMNode()).find(".form-control").each(function() {
- this.value = "";
+ $(this.getDOMNode()).find('.form-control').each(function() {
+ this.value = '';
});
- this.setState({current_password: '', new_password: '', confirm_password: '', server_error: null, password_error: null});
+ this.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null});
this.props.updateTab('general');
},
componentDidMount: function() {
@@ -533,40 +533,41 @@ var SecurityTab = React.createClass({
this.props.updateSection('');
},
getInitialState: function() {
- return { current_password: '', new_password: '', confirm_password: '' };
+ return {currentPassword: '', newPassword: '', confirmPassword: ''};
},
render: function() {
- var server_error = this.state.server_error ? this.state.server_error : null;
- var password_error = this.state.password_error ? this.state.password_error : null;
+ var serverError = this.state.serverError ? this.state.serverError : null;
+ var passwordError = this.state.passwordError ? this.state.passwordError : null;
+ var updateSectionStatus;
var passwordSection;
var self = this;
if (this.props.activeSection === 'password') {
var inputs = [];
var submit = null;
- if (this.props.user.auth_service === "") {
+ if (this.props.user.auth_service === '') {
inputs.push(
- <div className="form-group">
- <label className="col-sm-5 control-label">Current Password</label>
- <div className="col-sm-7">
- <input className="form-control" type="password" onChange={this.updateCurrentPassword} value={this.state.current_password}/>
+ <div className='form-group'>
+ <label className='col-sm-5 control-label'>Current Password</label>
+ <div className='col-sm-7'>
+ <input className='form-control' type='password' onChange={this.updateCurrentPassword} value={this.state.currentPassword}/>
</div>
</div>
);
inputs.push(
- <div className="form-group">
- <label className="col-sm-5 control-label">New Password</label>
- <div className="col-sm-7">
- <input className="form-control" type="password" onChange={this.updateNewPassword} value={this.state.new_password}/>
+ <div className='form-group'>
+ <label className='col-sm-5 control-label'>New Password</label>
+ <div className='col-sm-7'>
+ <input className='form-control' type='password' onChange={this.updateNewPassword} value={this.state.newPassword}/>
</div>
</div>
);
inputs.push(
- <div className="form-group">
- <label className="col-sm-5 control-label">Retype New Password</label>
- <div className="col-sm-7">
- <input className="form-control" type="password" onChange={this.updateConfirmPassword} value={this.state.confirm_password}/>
+ <div className='form-group'>
+ <label className='col-sm-5 control-label'>Retype New Password</label>
+ <div className='col-sm-7'>
+ <input className='form-control' type='password' onChange={this.updateConfirmPassword} value={this.state.confirmPassword}/>
</div>
</div>
);
@@ -574,58 +575,68 @@ var SecurityTab = React.createClass({
submit = this.submitPassword;
} else {
inputs.push(
- <div className="form-group">
- <label className="col-sm-12">Log in occurs through GitLab. Please see your GitLab account settings page to update your password.</label>
+ <div className='form-group'>
+ <label className='col-sm-12'>Log in occurs through GitLab. Please see your GitLab account settings page to update your password.</label>
</div>
);
}
+ updateSectionStatus = function(e) {
+ self.props.updateSection('');
+ self.setState({currentPassword: '', newPassword: '', confirmPassword: '', serverError: null, passwordError: null});
+ e.preventDefault();
+ };
+
passwordSection = (
<SettingItemMax
- title="Password"
+ title='Password'
inputs={inputs}
submit={submit}
- server_error={server_error}
- client_error={password_error}
- updateSection={function(e){self.props.updateSection("");e.preventDefault();}}
+ server_error={serverError}
+ client_error={passwordError}
+ updateSection={updateSectionStatus}
/>
);
} else {
var describe;
- if (this.props.user.auth_service === "") {
+ if (this.props.user.auth_service === '') {
var d = new Date(this.props.user.last_password_update);
- var hour = d.getHours() % 12 ? String(d.getHours() % 12) : "12";
- var min = d.getMinutes() < 10 ? "0" + d.getMinutes() : String(d.getMinutes());
- var timeOfDay = d.getHours() >= 12 ? " pm" : " am";
- describe = "Last updated " + Constants.MONTHS[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear() + " at " + hour + ":" + min + timeOfDay;
+ var hour = d.getHours() % 12 ? String(d.getHours() % 12) : '12';
+ var min = d.getMinutes() < 10 ? '0' + d.getMinutes() : String(d.getMinutes());
+ var timeOfDay = d.getHours() >= 12 ? ' pm' : ' am';
+ describe = 'Last updated ' + Constants.MONTHS[d.getMonth()] + ' ' + d.getDate() + ', ' + d.getFullYear() + ' at ' + hour + ':' + min + timeOfDay;
} else {
- describe = "Log in done through GitLab"
+ describe = 'Log in done through GitLab';
}
+ updateSectionStatus = function() {
+ self.props.updateSection('password');
+ };
+
passwordSection = (
<SettingItemMin
- title="Password"
+ title='Password'
describe={describe}
- updateSection={function(){self.props.updateSection("password");}}
+ updateSection={updateSectionStatus}
/>
);
}
return (
<div>
- <div className="modal-header">
- <button type="button" className="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- <h4 className="modal-title" ref="title"><i className="modal-back"></i>Security Settings</h4>
+ <div className='modal-header'>
+ <button type='button' className='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
+ <h4 className='modal-title' ref='title'><i className='modal-back'></i>Security Settings</h4>
</div>
- <div className="user-settings">
- <h3 className="tab-header">Security Settings</h3>
- <div className="divider-dark first"/>
- { passwordSection }
- <div className="divider-dark"/>
+ <div className='user-settings'>
+ <h3 className='tab-header'>Security Settings</h3>
+ <div className='divider-dark first'/>
+ {passwordSection}
+ <div className='divider-dark'/>
<br></br>
- <a data-toggle="modal" className="security-links theme" data-target="#access-history" href="#" onClick={this.handleHistoryOpen}><i className="fa fa-clock-o"></i>View Access History</a>
- <b> </b>
- <a data-toggle="modal" className="security-links theme" data-target="#activity-log" href="#" onClick={this.handleDevicesOpen}><i className="fa fa-globe"></i>View and Logout of Active Sessions</a>
+ <a data-toggle='modal' className='security-links theme' data-target='#access-history' href='#' onClick={this.handleHistoryOpen}><i className='fa fa-clock-o'></i>View Access History</a>
+ <b> </b>
+ <a data-toggle='modal' className='security-links theme' data-target='#activity-log' href='#' onClick={this.handleDevicesOpen}><i className='fa fa-globe'></i>View and Logout of Active Sessions</a>
</div>
</div>
);
diff --git a/web/react/stores/post_store.jsx b/web/react/stores/post_store.jsx
index ecf54ede6..ea1e75ecb 100644
--- a/web/react/stores/post_store.jsx
+++ b/web/react/stores/post_store.jsx
@@ -6,7 +6,6 @@ var EventEmitter = require('events').EventEmitter;
var assign = require('object-assign');
var ChannelStore = require('../stores/channel_store.jsx');
-var UserStore = require('../stores/user_store.jsx');
var BrowserStore = require('../stores/browser_store.jsx');
var Constants = require('../utils/constants.jsx');
@@ -21,185 +20,184 @@ var ADD_MENTION_EVENT = 'add_mention';
var PostStore = assign({}, EventEmitter.prototype, {
- emitChange: function() {
- this.emit(CHANGE_EVENT);
- },
-
- addChangeListener: function(callback) {
- this.on(CHANGE_EVENT, callback);
- },
-
- removeChangeListener: function(callback) {
- this.removeListener(CHANGE_EVENT, callback);
- },
-
- emitSearchChange: function() {
- this.emit(SEARCH_CHANGE_EVENT);
- },
-
- addSearchChangeListener: function(callback) {
- this.on(SEARCH_CHANGE_EVENT, callback);
- },
-
- removeSearchChangeListener: function(callback) {
- this.removeListener(SEARCH_CHANGE_EVENT, callback);
- },
-
- emitSearchTermChange: function(doSearch, isMentionSearch) {
- this.emit(SEARCH_TERM_CHANGE_EVENT, doSearch, isMentionSearch);
- },
-
- addSearchTermChangeListener: function(callback) {
- this.on(SEARCH_TERM_CHANGE_EVENT, callback);
- },
-
- removeSearchTermChangeListener: function(callback) {
- this.removeListener(SEARCH_TERM_CHANGE_EVENT, callback);
- },
-
- emitSelectedPostChange: function(from_search) {
- this.emit(SELECTED_POST_CHANGE_EVENT, from_search);
- },
-
- addSelectedPostChangeListener: function(callback) {
- this.on(SELECTED_POST_CHANGE_EVENT, callback);
- },
-
- removeSelectedPostChangeListener: function(callback) {
- this.removeListener(SELECTED_POST_CHANGE_EVENT, callback);
- },
-
- emitMentionDataChange: function(id, mentionText, excludeList) {
- this.emit(MENTION_DATA_CHANGE_EVENT, id, mentionText, excludeList);
- },
-
- addMentionDataChangeListener: function(callback) {
- this.on(MENTION_DATA_CHANGE_EVENT, callback);
- },
-
- removeMentionDataChangeListener: function(callback) {
- this.removeListener(MENTION_DATA_CHANGE_EVENT, callback);
- },
-
- emitAddMention: function(id, username) {
- this.emit(ADD_MENTION_EVENT, id, username);
- },
-
- addAddMentionListener: function(callback) {
- this.on(ADD_MENTION_EVENT, callback);
- },
-
- removeAddMentionListener: function(callback) {
- this.removeListener(ADD_MENTION_EVENT, callback);
- },
-
- getCurrentPosts: function() {
- var currentId = ChannelStore.getCurrentId();
-
- if (currentId != null)
- return this.getPosts(currentId);
- else
- return null;
- },
- storePosts: function(channelId, posts) {
- this._storePosts(channelId, posts);
- this.emitChange();
- },
- _storePosts: function(channelId, posts) {
- BrowserStore.setItem("posts_" + channelId, posts);
- },
- getPosts: function(channelId) {
- return BrowserStore.getItem("posts_" + channelId);
- },
- storeSearchResults: function(results, is_mention_search) {
- BrowserStore.setItem("search_results", results);
- is_mention_search = is_mention_search ? true : false; // force to bool
- BrowserStore.setItem("is_mention_search", is_mention_search);
- },
- getSearchResults: function() {
- return BrowserStore.getItem("search_results");
- },
- getIsMentionSearch: function() {
- return BrowserStore.getItem("is_mention_search");
- },
- storeSelectedPost: function(post_list) {
- BrowserStore.setItem("select_post", post_list);
- },
- getSelectedPost: function() {
- return BrowserStore.getItem("select_post");
- },
- storeSearchTerm: function(term) {
- BrowserStore.setItem("search_term", term);
- },
- getSearchTerm: function() {
- return BrowserStore.getItem("search_term");
- },
- storeCurrentDraft: function(draft) {
- var channel_id = ChannelStore.getCurrentId();
- BrowserStore.setItem("draft_" + channel_id, draft);
- },
- getCurrentDraft: function() {
- var channel_id = ChannelStore.getCurrentId();
- return BrowserStore.getItem("draft_" + channel_id);
- },
- storeDraft: function(channel_id, draft) {
- BrowserStore.setItem("draft_" + channel_id, draft);
- },
- getDraft: function(channel_id) {
- return BrowserStore.getItem("draft_" + channel_id);
- },
- storeCommentDraft: function(parent_post_id, draft) {
- BrowserStore.setItem("comment_draft_" + parent_post_id, draft);
- },
- getCommentDraft: function(parent_post_id) {
- return BrowserStore.getItem("comment_draft_" + parent_post_id);
- },
- clearDraftUploads: function() {
- BrowserStore.actionOnItemsWithPrefix("draft_", function (key, value) {
- if (value) {
- value.uploadsInProgress = 0;
- BrowserStore.setItem(key, value);
- }
- });
- },
- clearCommentDraftUploads: function() {
- BrowserStore.actionOnItemsWithPrefix("comment_draft_", function (key, value) {
- if (value) {
- value.uploadsInProgress = 0;
- BrowserStore.setItem(key, value);
- }
- });
- }
+ emitChange: function emitChange() {
+ this.emit(CHANGE_EVENT);
+ },
+
+ addChangeListener: function addChangeListener(callback) {
+ this.on(CHANGE_EVENT, callback);
+ },
+
+ removeChangeListener: function removeChangeListener(callback) {
+ this.removeListener(CHANGE_EVENT, callback);
+ },
+
+ emitSearchChange: function emitSearchChange() {
+ this.emit(SEARCH_CHANGE_EVENT);
+ },
+
+ addSearchChangeListener: function addSearchChangeListener(callback) {
+ this.on(SEARCH_CHANGE_EVENT, callback);
+ },
+
+ removeSearchChangeListener: function removeSearchChangeListener(callback) {
+ this.removeListener(SEARCH_CHANGE_EVENT, callback);
+ },
+
+ emitSearchTermChange: function emitSearchTermChange(doSearch, isMentionSearch) {
+ this.emit(SEARCH_TERM_CHANGE_EVENT, doSearch, isMentionSearch);
+ },
+
+ addSearchTermChangeListener: function addSearchTermChangeListener(callback) {
+ this.on(SEARCH_TERM_CHANGE_EVENT, callback);
+ },
+
+ removeSearchTermChangeListener: function removeSearchTermChangeListener(callback) {
+ this.removeListener(SEARCH_TERM_CHANGE_EVENT, callback);
+ },
+
+ emitSelectedPostChange: function emitSelectedPostChange(fromSearch) {
+ this.emit(SELECTED_POST_CHANGE_EVENT, fromSearch);
+ },
+
+ addSelectedPostChangeListener: function addSelectedPostChangeListener(callback) {
+ this.on(SELECTED_POST_CHANGE_EVENT, callback);
+ },
+
+ removeSelectedPostChangeListener: function removeSelectedPostChangeListener(callback) {
+ this.removeListener(SELECTED_POST_CHANGE_EVENT, callback);
+ },
+
+ emitMentionDataChange: function emitMentionDataChange(id, mentionText) {
+ this.emit(MENTION_DATA_CHANGE_EVENT, id, mentionText);
+ },
+
+ addMentionDataChangeListener: function addMentionDataChangeListener(callback) {
+ this.on(MENTION_DATA_CHANGE_EVENT, callback);
+ },
+
+ removeMentionDataChangeListener: function removeMentionDataChangeListener(callback) {
+ this.removeListener(MENTION_DATA_CHANGE_EVENT, callback);
+ },
+
+ emitAddMention: function emitAddMention(id, username) {
+ this.emit(ADD_MENTION_EVENT, id, username);
+ },
+
+ addAddMentionListener: function addAddMentionListener(callback) {
+ this.on(ADD_MENTION_EVENT, callback);
+ },
+
+ removeAddMentionListener: function removeAddMentionListener(callback) {
+ this.removeListener(ADD_MENTION_EVENT, callback);
+ },
+
+ getCurrentPosts: function getCurrentPosts() {
+ var currentId = ChannelStore.getCurrentId();
+
+ if (currentId != null) {
+ return this.getPosts(currentId);
+ }
+ return null;
+ },
+ storePosts: function storePosts(channelId, posts) {
+ this.pStorePosts(channelId, posts);
+ this.emitChange();
+ },
+ pStorePosts: function pStorePosts(channelId, posts) {
+ BrowserStore.setItem('posts_' + channelId, posts);
+ },
+ getPosts: function getPosts(channelId) {
+ return BrowserStore.getItem('posts_' + channelId);
+ },
+ storeSearchResults: function storeSearchResults(results, isMentionSearch) {
+ BrowserStore.setItem('search_results', results);
+ BrowserStore.setItem('is_mention_search', Boolean(isMentionSearch));
+ },
+ getSearchResults: function getSearchResults() {
+ return BrowserStore.getItem('search_results');
+ },
+ getIsMentionSearch: function getIsMentionSearch() {
+ return BrowserStore.getItem('is_mention_search');
+ },
+ storeSelectedPost: function storeSelectedPost(postList) {
+ BrowserStore.setItem('select_post', postList);
+ },
+ getSelectedPost: function getSelectedPost() {
+ return BrowserStore.getItem('select_post');
+ },
+ storeSearchTerm: function storeSearchTerm(term) {
+ BrowserStore.setItem('search_term', term);
+ },
+ getSearchTerm: function getSearchTerm() {
+ return BrowserStore.getItem('search_term');
+ },
+ storeCurrentDraft: function storeCurrentDraft(draft) {
+ var channelId = ChannelStore.getCurrentId();
+ BrowserStore.setItem('draft_' + channelId, draft);
+ },
+ getCurrentDraft: function getCurrentDraft() {
+ var channelId = ChannelStore.getCurrentId();
+ return BrowserStore.getItem('draft_' + channelId);
+ },
+ storeDraft: function storeDraft(channelId, draft) {
+ BrowserStore.setItem('draft_' + channelId, draft);
+ },
+ getDraft: function getDraft(channelId) {
+ return BrowserStore.getItem('draft_' + channelId);
+ },
+ storeCommentDraft: function storeCommentDraft(parentPostId, draft) {
+ BrowserStore.setItem('comment_draft_' + parentPostId, draft);
+ },
+ getCommentDraft: function getCommentDraft(parentPostId) {
+ return BrowserStore.getItem('comment_draft_' + parentPostId);
+ },
+ clearDraftUploads: function clearDraftUploads() {
+ BrowserStore.actionOnItemsWithPrefix('draft_', function clearUploads(key, value) {
+ if (value) {
+ value.uploadsInProgress = 0;
+ BrowserStore.setItem(key, value);
+ }
+ });
+ },
+ clearCommentDraftUploads: function clearCommentDraftUploads() {
+ BrowserStore.actionOnItemsWithPrefix('comment_draft_', function clearUploads(key, value) {
+ if (value) {
+ value.uploadsInProgress = 0;
+ BrowserStore.setItem(key, value);
+ }
+ });
+ }
});
-PostStore.dispatchToken = AppDispatcher.register(function(payload) {
- var action = payload.action;
-
- switch(action.type) {
- case ActionTypes.RECIEVED_POSTS:
- PostStore._storePosts(action.id, action.post_list);
- PostStore.emitChange();
- break;
- case ActionTypes.RECIEVED_SEARCH:
- PostStore.storeSearchResults(action.results, action.is_mention_search);
- PostStore.emitSearchChange();
- break;
- case ActionTypes.RECIEVED_SEARCH_TERM:
- PostStore.storeSearchTerm(action.term);
- PostStore.emitSearchTermChange(action.do_search, action.is_mention_search);
- break;
- case ActionTypes.RECIEVED_POST_SELECTED:
- PostStore.storeSelectedPost(action.post_list);
- PostStore.emitSelectedPostChange(action.from_search);
- break;
- case ActionTypes.RECIEVED_MENTION_DATA:
- PostStore.emitMentionDataChange(action.id, action.mention_text, action.exclude_list);
- break;
- case ActionTypes.RECIEVED_ADD_MENTION:
- PostStore.emitAddMention(action.id, action.username);
- break;
- default:
- }
+PostStore.dispatchToken = AppDispatcher.register(function registry(payload) {
+ var action = payload.action;
+
+ switch (action.type) {
+ case ActionTypes.RECIEVED_POSTS:
+ PostStore.pStorePosts(action.id, action.post_list);
+ PostStore.emitChange();
+ break;
+ case ActionTypes.RECIEVED_SEARCH:
+ PostStore.storeSearchResults(action.results, action.is_mention_search);
+ PostStore.emitSearchChange();
+ break;
+ case ActionTypes.RECIEVED_SEARCH_TERM:
+ PostStore.storeSearchTerm(action.term);
+ PostStore.emitSearchTermChange(action.do_search, action.is_mention_search);
+ break;
+ case ActionTypes.RECIEVED_POST_SELECTED:
+ PostStore.storeSelectedPost(action.post_list);
+ PostStore.emitSelectedPostChange(action.from_search);
+ break;
+ case ActionTypes.RECIEVED_MENTION_DATA:
+ PostStore.emitMentionDataChange(action.id, action.mention_text);
+ break;
+ case ActionTypes.RECIEVED_ADD_MENTION:
+ PostStore.emitAddMention(action.id, action.username);
+ break;
+ default:
+ }
});
module.exports = PostStore;
diff --git a/web/react/stores/user_store.jsx b/web/react/stores/user_store.jsx
index aff5a0bed..f8616c6ab 100644
--- a/web/react/stores/user_store.jsx
+++ b/web/react/stores/user_store.jsx
@@ -4,7 +4,6 @@
var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
var EventEmitter = require('events').EventEmitter;
var assign = require('object-assign');
-var client = require('../utils/client.jsx');
var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes;
@@ -18,244 +17,248 @@ var CHANGE_EVENT_STATUSES = 'change_statuses';
var UserStore = assign({}, EventEmitter.prototype, {
- _current_id: null,
+ gCurrentId: null,
- emitChange: function(userId) {
- this.emit(CHANGE_EVENT, userId);
- },
- addChangeListener: function(callback) {
- this.on(CHANGE_EVENT, callback);
- },
- removeChangeListener: function(callback) {
- this.removeListener(CHANGE_EVENT, callback);
- },
- emitSessionsChange: function() {
- this.emit(CHANGE_EVENT_SESSIONS);
- },
- addSessionsChangeListener: function(callback) {
- this.on(CHANGE_EVENT_SESSIONS, callback);
- },
- removeSessionsChangeListener: function(callback) {
- this.removeListener(CHANGE_EVENT_SESSIONS, callback);
- },
- emitAuditsChange: function() {
- this.emit(CHANGE_EVENT_AUDITS);
- },
- addAuditsChangeListener: function(callback) {
- this.on(CHANGE_EVENT_AUDITS, callback);
- },
- removeAuditsChangeListener: function(callback) {
- this.removeListener(CHANGE_EVENT_AUDITS, callback);
- },
- emitTeamsChange: function() {
- this.emit(CHANGE_EVENT_TEAMS);
- },
- addTeamsChangeListener: function(callback) {
- this.on(CHANGE_EVENT_TEAMS, callback);
- },
- removeTeamsChangeListener: function(callback) {
- this.removeListener(CHANGE_EVENT_TEAMS, callback);
- },
- emitStatusesChange: function() {
- this.emit(CHANGE_EVENT_STATUSES);
- },
- addStatusesChangeListener: function(callback) {
- this.on(CHANGE_EVENT_STATUSES, callback);
- },
- removeStatusesChangeListener: function(callback) {
- this.removeListener(CHANGE_EVENT_STATUSES, callback);
- },
- setCurrentId: function(id) {
- this._current_id = id;
- if (id == null) {
- BrowserStore.removeGlobalItem("current_user_id");
- } else {
- BrowserStore.setGlobalItem("current_user_id", id);
- }
- },
- getCurrentId: function(skipFetch) {
- var current_id = this._current_id;
+ emitChange: function(userId) {
+ this.emit(CHANGE_EVENT, userId);
+ },
+ addChangeListener: function(callback) {
+ this.on(CHANGE_EVENT, callback);
+ },
+ removeChangeListener: function(callback) {
+ this.removeListener(CHANGE_EVENT, callback);
+ },
+ emitSessionsChange: function() {
+ this.emit(CHANGE_EVENT_SESSIONS);
+ },
+ addSessionsChangeListener: function(callback) {
+ this.on(CHANGE_EVENT_SESSIONS, callback);
+ },
+ removeSessionsChangeListener: function(callback) {
+ this.removeListener(CHANGE_EVENT_SESSIONS, callback);
+ },
+ emitAuditsChange: function() {
+ this.emit(CHANGE_EVENT_AUDITS);
+ },
+ addAuditsChangeListener: function(callback) {
+ this.on(CHANGE_EVENT_AUDITS, callback);
+ },
+ removeAuditsChangeListener: function(callback) {
+ this.removeListener(CHANGE_EVENT_AUDITS, callback);
+ },
+ emitTeamsChange: function() {
+ this.emit(CHANGE_EVENT_TEAMS);
+ },
+ addTeamsChangeListener: function(callback) {
+ this.on(CHANGE_EVENT_TEAMS, callback);
+ },
+ removeTeamsChangeListener: function(callback) {
+ this.removeListener(CHANGE_EVENT_TEAMS, callback);
+ },
+ emitStatusesChange: function() {
+ this.emit(CHANGE_EVENT_STATUSES);
+ },
+ addStatusesChangeListener: function(callback) {
+ this.on(CHANGE_EVENT_STATUSES, callback);
+ },
+ removeStatusesChangeListener: function(callback) {
+ this.removeListener(CHANGE_EVENT_STATUSES, callback);
+ },
+ setCurrentId: function(id) {
+ this.gCurrentId = id;
+ if (id == null) {
+ BrowserStore.removeGlobalItem('current_user_id');
+ } else {
+ BrowserStore.setGlobalItem('current_user_id', id);
+ }
+ },
+ getCurrentId: function() {
+ var currentId = this.gCurrentId;
- if (current_id == null) {
- current_id = BrowserStore.getGlobalItem("current_user_id");
- }
+ if (currentId == null) {
+ currentId = BrowserStore.getGlobalItem('current_user_id');
+ this.gCurrentId = currentId;
+ }
- // this is a speical case to force fetch the
- // current user if it's missing
- // it's synchronous to block rendering
- if (current_id == null && !skipFetch) {
- var me = client.getMeSynchronous();
- if (me != null) {
- this.setCurrentUser(me);
- current_id = me.id;
- }
- }
+ return currentId;
+ },
+ getCurrentUser: function() {
+ if (this.getCurrentId() == null) {
+ return null;
+ }
- return current_id;
- },
- getCurrentUser: function(skipFetch) {
- if (this.getCurrentId(skipFetch) == null) {
- return null;
- }
+ return this._getProfiles()[this.getCurrentId()];
+ },
+ setCurrentUser: function(user) {
+ this.setCurrentId(user.id);
+ 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()];
- },
- setCurrentUser: function(user) {
- this.setCurrentId(user.id);
- 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();
+ },
+ getActiveOnlyProfiles: function() {
+ var active = {};
+ var current = this._getProfiles();
- return this._getProfiles();
- },
- getActiveOnlyProfiles: function() {
- active = {};
- current = this._getProfiles();
+ for (var key in current) {
+ if (current[key].delete_at === 0) {
+ active[key] = current[key];
+ }
+ }
- for (var key in current) {
- if (current[key].delete_at == 0) {
- active[key] = current[key];
- }
- }
+ return active;
+ },
+ 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;
- },
- 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 = [];
- var keys = [];
+ if (!user || !user.notify_props) {
+ return keys;
+ }
- if (!user)
- return keys;
+ if (user.notify_props.mention_keys) {
+ keys = keys.concat(user.notify_props.mention_keys.split(','));
+ }
- if (user.notify_props && user.notify_props.mention_keys) keys = keys.concat(user.notify_props.mention_keys.split(','));
- if (user.first_name && user.notify_props.first_name === "true") 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.notify_props.first_name === 'true' && user.first_name) {
+ keys.push(user.first_name);
+ }
- return keys;
- },
- getLastVersion: function() {
- return BrowserStore.getItem("last_version", '');
- },
- setLastVersion: function(version) {
- BrowserStore.setItem("last_version", version);
- },
- setStatuses: function(statuses) {
- this._setStatuses(statuses);
- this.emitStatusesChange();
- },
- _setStatuses: function(statuses) {
- BrowserStore.setItem("statuses", statuses);
- },
- setStatus: function(user_id, status) {
- var statuses = this.getStatuses();
- statuses[user_id] = status;
- this._setStatuses(statuses);
- this.emitStatusesChange();
- },
- getStatuses: function() {
- return BrowserStore.getItem("statuses", {});
- },
- getStatus: function(id) {
- return this.getStatuses()[id];
- }
+ if (user.notify_props.all === 'true') {
+ keys.push('@all');
+ }
+
+ if (user.notify_props.channel === 'true') {
+ keys.push('@channel');
+ }
+
+ return keys;
+ },
+ getLastVersion: function() {
+ return BrowserStore.getItem('last_version', '');
+ },
+ setLastVersion: function(version) {
+ BrowserStore.setItem('last_version', version);
+ },
+ setStatuses: function(statuses) {
+ this._setStatuses(statuses);
+ this.emitStatusesChange();
+ },
+ _setStatuses: function(statuses) {
+ BrowserStore.setItem('statuses', statuses);
+ },
+ setStatus: function(userId, status) {
+ var statuses = this.getStatuses();
+ statuses[userId] = status;
+ this._setStatuses(statuses);
+ this.emitStatusesChange();
+ },
+ getStatuses: function() {
+ return BrowserStore.getItem('statuses', {});
+ },
+ getStatus: function(id) {
+ return this.getStatuses()[id];
+ }
});
UserStore.dispatchToken = AppDispatcher.register(function(payload) {
- var action = payload.action;
+ var action = payload.action;
- switch(action.type) {
- case ActionTypes.RECIEVED_PROFILES:
- for(var id in action.profiles) {
- // profiles can have incomplete data, so don't overwrite current user
- if (id === UserStore.getCurrentId()) continue;
- var profile = action.profiles[id];
- UserStore.saveProfile(profile);
- UserStore.emitChange(profile.id);
- }
- break;
- case ActionTypes.RECIEVED_ME:
- UserStore.setCurrentUser(action.me);
- UserStore.emitChange(action.me.id);
- break;
- case ActionTypes.RECIEVED_SESSIONS:
- UserStore.setSessions(action.sessions);
- UserStore.emitSessionsChange();
- break;
- case ActionTypes.RECIEVED_AUDITS:
- UserStore.setAudits(action.audits);
- UserStore.emitAuditsChange();
- break;
- case ActionTypes.RECIEVED_TEAMS:
- UserStore.setTeams(action.teams);
- UserStore.emitTeamsChange();
- break;
- case ActionTypes.RECIEVED_STATUSES:
- UserStore._setStatuses(action.statuses);
- UserStore.emitStatusesChange();
- break;
+ switch (action.type) {
+ case ActionTypes.RECIEVED_PROFILES:
+ for (var id in action.profiles) {
+ // profiles can have incomplete data, so don't overwrite current user
+ if (id === UserStore.getCurrentId()) {
+ continue;
+ }
+ var profile = action.profiles[id];
+ UserStore.saveProfile(profile);
+ UserStore.emitChange(profile.id);
+ }
+ break;
+ case ActionTypes.RECIEVED_ME:
+ UserStore.setCurrentUser(action.me);
+ UserStore.emitChange(action.me.id);
+ break;
+ case ActionTypes.RECIEVED_SESSIONS:
+ UserStore.setSessions(action.sessions);
+ UserStore.emitSessionsChange();
+ break;
+ case ActionTypes.RECIEVED_AUDITS:
+ UserStore.setAudits(action.audits);
+ UserStore.emitAuditsChange();
+ break;
+ case ActionTypes.RECIEVED_TEAMS:
+ UserStore.setTeams(action.teams);
+ UserStore.emitTeamsChange();
+ break;
+ case ActionTypes.RECIEVED_STATUSES:
+ UserStore._setStatuses(action.statuses);
+ UserStore.emitStatusesChange();
+ break;
- default:
- }
+ default:
+ }
});
UserStore.setMaxListeners(0);
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index dc4fc1096..f35b0f6cc 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -322,7 +322,7 @@ module.exports.getMe = function() {
if (isCallInProgress("getMe")) return;
callTracker["getMe"] = utils.getTimestamp();
- client.getMeSynchronous(
+ client.getMe(
function(data, textStatus, xhr) {
callTracker["getMe"] = 0;
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index b8eda0075..3375da7cf 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -279,32 +279,24 @@ module.exports.getAudits = function(userId, success, error) {
});
};
-module.exports.getMeSynchronous = function(success, error) {
-
- var current_user = null;
+module.exports.getMe = function(success, error) {
$.ajax({
- async: false,
url: "/api/v1/users/me",
dataType: 'json',
contentType: 'application/json',
type: 'GET',
- success: function(data, textStatus, xhr) {
- current_user = data;
- if (success) success(data, textStatus, xhr);
- },
+ success: success,
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
if (xhr.status != 200 || !(ieChecker.indexOf("Trident/7.0") > 0 || ieChecker.indexOf("Trident/6.0") > 0)) {
if (error) {
- e = handleError("getMeSynchronous", xhr, status, err);
+ e = handleError("getMe", xhr, status, err);
error(e);
};
};
}
});
-
- return current_user;
};
module.exports.inviteMembers = function(data, success, error) {