Chats: fix #418 scrolling resize issue

This commit is contained in:
Alex Gleason 2020-09-11 22:44:09 -05:00
parent 0c15e3235a
commit 5682688aed
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -89,11 +89,16 @@ class ChatMessageList extends ImmutablePureComponent {
return scrollBottom < elem.offsetHeight * 1.5;
}
handleResize = (e) => {
if (this.isNearBottom()) this.scrollToBottom();
}
componentDidMount() {
const { dispatch, chatId } = this.props;
dispatch(fetchChatMessages(chatId));
this.node.addEventListener('scroll', this.handleScroll);
window.addEventListener('resize', this.handleResize);
this.scrollToBottom();
}
@ -125,6 +130,7 @@ class ChatMessageList extends ImmutablePureComponent {
componentWillUnmount() {
this.node.removeEventListener('scroll', this.handleScroll);
window.removeEventListener('resize', this.handleResize);
}
handleLoadMore = () => {