Turn previews on for DMs and ensure they get rendered

This commit is contained in:
Travis Ralston 2020-07-14 12:49:29 -06:00
parent d74e803fa9
commit b19ae3ac93
2 changed files with 16 additions and 3 deletions

View file

@ -54,6 +54,7 @@ import defaultDispatcher from "../../../dispatcher/dispatcher";
import {ActionPayload} from "../../../dispatcher/payloads";
import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore";
import { NotificationState } from "../../../stores/notifications/NotificationState";
import { UPDATE_EVENT } from "../../../stores/AsyncStore";
// TODO: Rename on launch: https://github.com/vector-im/riot-web/issues/14367
@ -128,6 +129,7 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
};
ActiveRoomObserver.addListener(this.props.room.roomId, this.onActiveRoomUpdate);
MessagePreviewStore.instance.on(UPDATE_EVENT, this.onPreviewUpdated);
this.dispatcherRef = defaultDispatcher.register(this.onAction);
}
@ -150,9 +152,14 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
if (this.props.room) {
ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate);
}
MessagePreviewStore.instance.off(UPDATE_EVENT, this.onPreviewUpdated);
defaultDispatcher.unregister(this.dispatcherRef);
}
private onPreviewUpdated = () => {
this.forceUpdate(); // we don't track the preview in state, so just re-render
};
private onAction = (payload: ActionPayload) => {
if (payload.action === "view_room" && payload.room_id === this.props.room.roomId && payload.show_room_tile) {
setImmediate(() => {