diff --git a/src/components/structures/LeftPanel.tsx b/src/components/structures/LeftPanel.tsx index 44b404bd3a..7f9ef7516e 100644 --- a/src/components/structures/LeftPanel.tsx +++ b/src/components/structures/LeftPanel.tsx @@ -416,7 +416,7 @@ export default class LeftPanel extends React.Component { const roomList = { onResize={this.props.onResize} showSkeleton={showSkeleton} extraTiles={extraTiles} + resizeNotifier={this.props.resizeNotifier} alwaysVisible={ALWAYS_VISIBLE_TAGS.includes(orderedTagId)} /> }); diff --git a/src/components/views/rooms/RoomSublist.tsx b/src/components/views/rooms/RoomSublist.tsx index fb367349a2..dd80e9d40a 100644 --- a/src/components/views/rooms/RoomSublist.tsx +++ b/src/components/views/rooms/RoomSublist.tsx @@ -44,6 +44,7 @@ import { ActionPayload } from "../../../dispatcher/payloads"; import { Enable, Resizable } from "re-resizable"; import { Direction } from "re-resizable/lib/resizer"; import { polyfillTouchEvent } from "../../../@types/polyfill"; +import { ResizeNotifier } from "../../../utils/ResizeNotifier"; import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore"; import RoomListLayoutStore from "../../../stores/room-list/RoomListLayoutStore"; import { arrayFastClone, arrayHasOrderChange } from "../../../utils/arrays"; @@ -75,7 +76,7 @@ interface IProps { onResize: () => void; showSkeleton?: boolean; alwaysVisible?: boolean; - + resizeNotifier: ResizeNotifier; extraTiles?: ReactComponentElement[]; // TODO: Account for https://github.com/vector-im/element-web/issues/14179 @@ -528,6 +529,7 @@ export default class RoomSublist extends React.Component { tiles.push(; @@ -102,6 +104,9 @@ export default class RoomTile extends React.PureComponent { }; this.notificationState = RoomNotificationStateStore.instance.getRoomState(this.props.room); this.roomProps = EchoChamber.forRoom(this.props.room); + if (this.props.resizeNotifier) { + this.props.resizeNotifier.on("middlePanelResized", this.onResize); + } } private countUnsentEvents(): number { @@ -116,6 +121,12 @@ export default class RoomTile extends React.PureComponent { this.forceUpdate(); // notification state changed - update }; + private onResize = () => { + if (this.showMessagePreview && !this.state.messagePreview) { + this.setState({messagePreview: this.generatePreview()}); + } + }; + private onLocalEchoUpdated = (ev: MatrixEvent, room: Room) => { if (!room?.roomId === this.props.room.roomId) return; this.setState({hasUnsentEvents: this.countUnsentEvents() > 0}); @@ -195,6 +206,9 @@ export default class RoomTile extends React.PureComponent { ); this.props.room.off("Room.name", this.onRoomNameUpdate); } + if (this.props.resizeNotifier) { + this.props.resizeNotifier.off("middlePanelResized", this.onResize); + } ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate); defaultDispatcher.unregister(this.dispatcherRef); this.notificationState.off(NOTIFICATION_STATE_UPDATE, this.onNotificationUpdate);