Performance improvments (#2869)
Этот коммит содержится в:
коммит произвёл
Joram Wilander
родитель
1cf9432524
Коммит
274a2a58f0
@@ -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;
|
||||
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);
|
||||
}
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var oldLink = document.getElementById('favicon');
|
||||
if (oldLink) {
|
||||
head.removeChild(oldLink);
|
||||
}
|
||||
head.appendChild(link);
|
||||
|
||||
var directMessageMore = (
|
||||
<li key='more'>
|
||||
|
||||
Ссылка в новой задаче
Block a user