From 8f1b11a3947ee7f6eb85234518763e06580a63f2 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 4 Sep 2020 18:08:53 -0500 Subject: [PATCH] Chats: move messages fetch logic into ChatMessageList --- app/soapbox/features/chats/components/chat_box.js | 6 ------ app/soapbox/features/chats/components/chat_message_list.js | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/soapbox/features/chats/components/chat_box.js b/app/soapbox/features/chats/components/chat_box.js index 387a0f944..12b28d513 100644 --- a/app/soapbox/features/chats/components/chat_box.js +++ b/app/soapbox/features/chats/components/chat_box.js @@ -5,7 +5,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import { injectIntl, defineMessages } from 'react-intl'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { - fetchChatMessages, sendChatMessage, markChatRead, } from 'soapbox/actions/chats'; @@ -81,11 +80,6 @@ class ChatBox extends ImmutablePureComponent { onSetInputRef(el); }; - componentDidMount() { - const { dispatch, chatId } = this.props; - dispatch(fetchChatMessages(chatId)); - } - componentDidUpdate(prevProps) { const markReadConditions = [ () => this.props.chat !== undefined, diff --git a/app/soapbox/features/chats/components/chat_message_list.js b/app/soapbox/features/chats/components/chat_message_list.js index 45b597577..baa50a08f 100644 --- a/app/soapbox/features/chats/components/chat_message_list.js +++ b/app/soapbox/features/chats/components/chat_message_list.js @@ -80,6 +80,9 @@ class ChatMessageList extends ImmutablePureComponent { } componentDidMount() { + const { dispatch, chatId } = this.props; + dispatch(fetchChatMessages(chatId)); + this.node.addEventListener('scroll', this.handleScroll); }