summaryrefslogtreecommitdiffstats
path: root/webapp/components/sidebar.jsx
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-05-04 10:10:19 -0400
committerJoram Wilander <jwawilander@gmail.com>2016-05-04 10:10:19 -0400
commit274a2a58f0cb420b1b24495dcaa7ae2d2ffd7bec (patch)
tree2296d02067c52914c0a8eac9c6b3b9abe53d4676 /webapp/components/sidebar.jsx
parent1cf9432524914f538a33dad94d15251be12f7568 (diff)
downloadchat-274a2a58f0cb420b1b24495dcaa7ae2d2ffd7bec.tar.gz
chat-274a2a58f0cb420b1b24495dcaa7ae2d2ffd7bec.tar.bz2
chat-274a2a58f0cb420b1b24495dcaa7ae2d2ffd7bec.zip
Performance improvments (#2869)
Diffstat (limited to 'webapp/components/sidebar.jsx')
-rw-r--r--webapp/components/sidebar.jsx43
1 files changed, 17 insertions, 26 deletions
diff --git a/webapp/components/sidebar.jsx b/webapp/components/sidebar.jsx
index 4ce89d37c..71091f12b 100644
--- a/webapp/components/sidebar.jsx
+++ b/webapp/components/sidebar.jsx
@@ -47,7 +47,6 @@ export default class Sidebar extends React.Component {
this.onScroll = this.onScroll.bind(this);
this.updateUnreadIndicators = this.updateUnreadIndicators.bind(this);
this.handleLeaveDirectChannel = this.handleLeaveDirectChannel.bind(this);
- this.handleResize = this.handleResize.bind(this);
this.showMoreChannelsModal = this.showMoreChannelsModal.bind(this);
this.showNewChannelModal = this.showNewChannelModal.bind(this);
@@ -64,7 +63,6 @@ export default class Sidebar extends React.Component {
state.newChannelModalType = '';
state.showDirectChannelsModal = false;
state.loadingDMChannel = -1;
- state.windowWidth = Utils.windowWidth();
this.state = state;
}
getTotalUnreadCount() {
@@ -150,8 +148,6 @@ export default class Sidebar extends React.Component {
this.updateTitle();
this.updateUnreadIndicators();
-
- window.addEventListener('resize', this.handleResize);
}
shouldComponentUpdate(nextProps, nextState) {
if (!Utils.areObjectsEqual(nextState, this.state)) {
@@ -173,20 +169,12 @@ export default class Sidebar extends React.Component {
}
}
componentWillUnmount() {
- window.removeEventListener('resize', this.handleResize);
-
ChannelStore.removeChangeListener(this.onChange);
UserStore.removeChangeListener(this.onChange);
UserStore.removeStatusesChangeListener(this.onChange);
TeamStore.removeChangeListener(this.onChange);
PreferenceStore.removeChangeListener(this.onChange);
}
- handleResize() {
- this.setState({
- windowWidth: Utils.windowWidth(),
- windowHeight: Utils.windowHeight()
- });
- }
onChange() {
this.setState(this.getStateFromStores());
}
@@ -492,6 +480,7 @@ export default class Sidebar extends React.Component {
return (<div/>);
}
+ this.lastBadgesActive = this.badgesActive;
this.badgesActive = false;
// keep track of the first and last unread channels so we can use them to set the unread indicators
@@ -508,21 +497,23 @@ export default class Sidebar extends React.Component {
});
// update the favicon to show if there are any notifications
- var link = document.createElement('link');
- link.type = 'image/x-icon';
- link.rel = 'shortcut icon';
- link.id = 'favicon';
- if (this.badgesActive) {
- link.href = redFavicon;
- } else {
- link.href = favicon;
- }
- var head = document.getElementsByTagName('head')[0];
- var oldLink = document.getElementById('favicon');
- if (oldLink) {
- head.removeChild(oldLink);
+ if (this.lastBadgesActive !== this.badgesActive) {
+ var link = document.createElement('link');
+ link.type = 'image/x-icon';
+ link.rel = 'shortcut icon';
+ link.id = 'favicon';
+ if (this.badgesActive) {
+ link.href = redFavicon;
+ } else {
+ link.href = favicon;
+ }
+ var head = document.getElementsByTagName('head')[0];
+ var oldLink = document.getElementById('favicon');
+ if (oldLink) {
+ head.removeChild(oldLink);
+ }
+ head.appendChild(link);
}
- head.appendChild(link);
var directMessageMore = (
<li key='more'>