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.
pull/21833/head
Travis Ralston 2020-08-10 20:52:05 -06:00
parent be2d0c9de7
commit d866b2d9ef
1 changed files with 6 additions and 0 deletions

View File

@ -120,6 +120,12 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
return !this.props.isMinimized && this.props.showMessagePreview;
}
public componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>) {
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) {