diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 375545f819..b8dae41ef8 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -23,6 +23,7 @@ import classNames from 'classnames'; import shouldHideEvent from '../../shouldHideEvent'; import {wantsDateSeparator} from '../../DateUtils'; import * as sdk from '../../index'; +import dis from "../../dispatcher/dispatcher"; import {MatrixClientPeg} from '../../MatrixClientPeg'; import SettingsStore from '../../settings/SettingsStore'; @@ -207,11 +208,13 @@ export default class MessagePanel extends React.Component { componentDidMount() { this._isMounted = true; + this.dispatcherRef = dis.register(this.onAction); } componentWillUnmount() { this._isMounted = false; SettingsStore.unwatchSetting(this._showTypingNotificationsWatcherRef); + dis.unregister(this.dispatcherRef); } componentDidUpdate(prevProps, prevState) { @@ -224,6 +227,14 @@ export default class MessagePanel extends React.Component { } } + onAction = (payload) => { + switch (payload.action) { + case "message_sent": + this.scrollToBottom(); + break; + } + } + onShowTypingNotificationsChange = () => { this.setState({ showTypingNotifications: SettingsStore.getValue("showTypingNotifications"),