diff --git a/bigbluebutton-html5/imports/ui/components/chat/message-list/component.jsx b/bigbluebutton-html5/imports/ui/components/chat/message-list/component.jsx index 5c28841ac1995d91f6eb39c22801396c37c7e27b..76ce1d7b9c7d9b986d4a51b27912111d3d98c64f 100644 --- a/bigbluebutton-html5/imports/ui/components/chat/message-list/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/chat/message-list/component.jsx @@ -87,12 +87,12 @@ class MessageList extends Component { } } - componentDidUpdate() { - const { scrollPosition } = this.props; + componentDidUpdate(prevProps) { + const { scrollPosition, chatId } = this.props; if (this.shouldScrollBottom) { this.scrollTo(); - } else { + } else if (prevProps.chatId !== chatId) { this.scrollTo(scrollPosition); } } @@ -111,6 +111,16 @@ class MessageList extends Component { scrollArea.removeEventListener('scroll', this.handleScrollChange, false); } + shouldComponentUpdate(nextProps) { + if (this.props.chatId !== nextProps.chatId + || this.props.messages.length !== nextProps.messages.length + || !_.isEqual(this.props.messages, nextProps.messages)) { + return true; + } + + return false; + } + render() { const { messages } = this.props;