Merge branch 'chats-keyboard-mobile' into 'develop'

Chats: fix #418 scrolling resize issue

Closes #418

See merge request soapbox-pub/soapbox-fe!233
This commit is contained in:
Alex Gleason 2020-09-12 03:56:32 +00:00
commit c2ae225db1

View file

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