Prevent unnecessary wrapWidth updates

This commit is contained in:
Ken-Håvard Lieng 2017-03-28 23:55:50 +02:00
parent 3b0734bb4d
commit bb8a4d180e
2 changed files with 28 additions and 25 deletions

File diff suppressed because one or more lines are too long

View File

@ -32,12 +32,16 @@ export default class MessageBox extends PureComponent {
listRef = el => { this.list = el; };
updateWidth = () => {
updateWidth = (width) => {
const { isChannel, setWrapWidth, updateMessageHeight } = this.props;
let wrapWidth = this.width;
let wrapWidth = width || this.width;
if (isChannel) {
wrapWidth += 200;
if (width) {
if (isChannel && window.innerWidth > 600) {
wrapWidth += 200;
}
this.width = wrapWidth;
}
// eslint-disable-next-line no-underscore-dangle
@ -54,8 +58,7 @@ export default class MessageBox extends PureComponent {
};
handleResize = size => {
this.width = size.width - 30;
this.updateWidth();
this.updateWidth(size.width - 30);
};
handleScroll = ({ scrollTop, clientHeight, scrollHeight }) => {