From c7e61ac71d090be8f4880af02edc461447026953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 21 Jan 2021 17:32:57 +0100 Subject: [PATCH] Rerender MessagePanel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/MessagePanel.js | 11 +++++++++++ src/components/views/messages/TextualBody.js | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 375545f819..4298e75b32 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -32,6 +32,7 @@ import {textForEvent} from "../../TextForEvent"; import IRCTimelineProfileResizer from "../views/elements/IRCTimelineProfileResizer"; import DMRoomMap from "../../utils/DMRoomMap"; import NewRoomIntro from "../views/rooms/NewRoomIntro"; +import dis from "../../dispatcher/dispatcher"; const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes const continuedTypes = ['m.sticker', 'm.room.message']; @@ -203,6 +204,16 @@ export default class MessagePanel extends React.Component { this._showTypingNotificationsWatcherRef = SettingsStore.watchSetting("showTypingNotifications", null, this.onShowTypingNotificationsChange); + + dis.register(this.onAction); + } + + onAction = payload => { + switch (payload.action) { + case "rerender_MessagePanel": + this.forceUpdate(); + break; + } } componentDidMount() { diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index a9f73404e9..45df78d480 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -147,6 +147,10 @@ export default class TextualBody extends React.Component { pre.className = "mx_EventTile_collapsedCodeBlock"; button.className += "mx_EventTile_expandButton"; } + /* Now we need to rerender the MessagePanel because the + * content's size has changed. Otherwise scrolling could + * get broken */ + dis.dispatch({action: "rerender_MessagePanel"}); }; div.appendChild(button);