summaryrefslogtreecommitdiffstats
path: root/web/react/components/sidebar.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'web/react/components/sidebar.jsx')
-rw-r--r--web/react/components/sidebar.jsx42
1 files changed, 22 insertions, 20 deletions
diff --git a/web/react/components/sidebar.jsx b/web/react/components/sidebar.jsx
index 59e93d7e6..6883cd4f0 100644
--- a/web/react/components/sidebar.jsx
+++ b/web/react/components/sidebar.jsx
@@ -1,7 +1,6 @@
// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved.
// See License.txt for license information.
-var AppDispatcher = require('../dispatcher/app_dispatcher.jsx');
var ChannelStore = require('../stores/channel_store.jsx');
var Client = require('../utils/client.jsx');
var AsyncClient = require('../utils/async_client.jsx');
@@ -12,9 +11,7 @@ var BrowserStore = require('../stores/browser_store.jsx');
var utils = require('../utils/utils.jsx');
var SidebarHeader = require('./sidebar_header.jsx');
var SearchBox = require('./search_bar.jsx');
-
var Constants = require('../utils/constants.jsx');
-var ActionTypes = Constants.ActionTypes;
function getStateFromStores() {
var members = ChannelStore.getAllMembers();
@@ -78,7 +75,7 @@ function getStateFromStores() {
// If we don't have MAX_DMS unread channels, sort the read list by last_post_at
if (showDirectChannels.length < Constants.MAX_DMS) {
- readDirectChannels.sort(function(a, b) {
+ readDirectChannels.sort(function sortByLastPost(a, b) {
// sort by last_post_at first
if (a.last_post_at > b.last_post_at) {
return -1;
@@ -126,6 +123,10 @@ function getStateFromStores() {
module.exports = React.createClass({
displayName: 'Sidebar',
+ propTypes: {
+ teamType: React.PropTypes.string,
+ teamDisplayName: React.PropTypes.string
+ },
componentDidMount: function() {
ChannelStore.addChangeListener(this.onChange);
UserStore.addChangeListener(this.onChange);
@@ -246,17 +247,17 @@ module.exports = React.createClass({
var channel = ChannelStore.getCurrent();
if (channel) {
if (channel.type === 'D') {
- var teammate_username = utils.getDirectTeammate(channel.id).username;
- document.title = teammate_username + ' ' + document.title.substring(document.title.lastIndexOf('-'));
+ var teammateUsername = utils.getDirectTeammate(channel.id).username;
+ document.title = teammateUsername + ' ' + document.title.substring(document.title.lastIndexOf('-'));
} else {
document.title = channel.display_name + ' ' + document.title.substring(document.title.lastIndexOf('-'));
}
}
},
- onScroll: function(e) {
+ onScroll: function() {
this.updateUnreadIndicators();
},
- onResize: function(e) {
+ onResize: function() {
this.updateUnreadIndicators();
},
updateUnreadIndicators: function() {
@@ -301,6 +302,7 @@ module.exports = React.createClass({
function createChannelElement(channel, index) {
var channelMember = members[channel.id];
+ var msgCount;
var linkClass = '';
if (channel.id === activeId) {
@@ -309,7 +311,7 @@ module.exports = React.createClass({
var unread = false;
if (channelMember) {
- var msgCount = channel.total_msg_count - channelMember.msg_count;
+ msgCount = channel.total_msg_count - channelMember.msg_count;
unread = (msgCount > 0 && channelMember.notify_level !== 'quiet') || channelMember.mention_count > 0;
}
@@ -327,7 +329,7 @@ module.exports = React.createClass({
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;
+ msgCount = channel.total_msg_count - channelMember.msg_count;
if (msgCount > 0) {
badge = <span className='badge pull-right small'>{msgCount}</span>;
badgesActive = true;
@@ -359,12 +361,12 @@ module.exports = React.createClass({
}
// set up click handler to switch channels (or create a new channel for non-existant ones)
- var clickHandler = null;
+ var handleClick = null;
var href = '#';
var teamURL = TeamStore.getCurrentTeamUrl();
if (!channel.fake) {
- clickHandler = function(e) {
+ handleClick = function clickHandler(e) {
e.preventDefault();
utils.switchChannel(channel);
};
@@ -378,17 +380,17 @@ module.exports = React.createClass({
otherUserId = ids[0];
}
- clickHandler = function(e) {
+ handleClick = function clickHandler(e) {
e.preventDefault();
self.setState({loadingPMChannel: index});
Client.createPMChannelIfNotExists(channel, otherUserId,
- function(data) {
+ function success(data) {
self.setState({loadingPMChannel: -1});
AsyncClient.getChannel(data.id);
utils.switchChannel(data);
},
- function() {
+ function error() {
self.setState({loadingPMChannel: -1});
window.location.href = teamURL + '/channels/' + channel.name;
}
@@ -398,24 +400,24 @@ module.exports = React.createClass({
return (
<li key={channel.name} ref={channel.name} className={linkClass}>
- <a className={'sidebar-channel ' + titleClass} href={href} onClick={clickHandler}>
+ <a className={'sidebar-channel ' + titleClass} href={href} onClick={handleClick}>
{status}
{channel.display_name}
{badge}
</a>
</li>
);
- };
+ }
// create elements for all 3 types of channels
var channelItems = this.state.channels.filter(
- function(channel) {
+ function filterPublicChannels(channel) {
return channel.type === 'O';
}
).map(createChannelElement);
var privateChannelItems = this.state.channels.filter(
- function(channel) {
+ function filterPrivateChannels(channel) {
return channel.type === 'P';
}
).map(createChannelElement);
@@ -444,7 +446,7 @@ module.exports = React.createClass({
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+')'}
+ {'More (' + this.state.hideDirectChannels.length + ')'}
</a>
</li>
);