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.
This commit is contained in:
Travis Ralston 2020-08-10 20:52:05 -06:00
parent be2d0c9de7
commit d866b2d9ef

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) {