From d866b2d9ef8e503e86de978d7a4ddf49ed26a770 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 10 Aug 2020 20:52:05 -0600 Subject: [PATCH] Generate previews for rooms when the option changes Fixes https://github.com/vector-im/element-web/issues/14853 This likely regressed in https://github.com/matrix-org/matrix-react-sdk/pull/5048 when the message preview information was made state, and the component wasn't updating the preview when the control flags changed. --- src/components/views/rooms/RoomTile.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/views/rooms/RoomTile.tsx b/src/components/views/rooms/RoomTile.tsx index 7c5c5b469b..09f201e3ef 100644 --- a/src/components/views/rooms/RoomTile.tsx +++ b/src/components/views/rooms/RoomTile.tsx @@ -120,6 +120,12 @@ export default class RoomTile extends React.PureComponent { return !this.props.isMinimized && this.props.showMessagePreview; } + public componentDidUpdate(prevProps: Readonly, prevState: Readonly) { + if (prevProps.showMessagePreview !== this.props.showMessagePreview && this.showMessagePreview) { + this.setState({messagePreview: this.generatePreview()}); + } + } + public componentDidMount() { // when we're first rendered (or our sublist is expanded) make sure we are visible if we're active if (this.state.selected) {