From d2de115b2f5f0aab5adbfb38b80a025a52a2dd1d Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Thu, 29 Apr 2021 21:37:44 +0530 Subject: [PATCH 1/3] Generate room preview even when minimized Signed-off-by: Jaiwanth --- src/components/views/rooms/RoomTile.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/rooms/RoomTile.tsx b/src/components/views/rooms/RoomTile.tsx index 8521992fa1..07dca95284 100644 --- a/src/components/views/rooms/RoomTile.tsx +++ b/src/components/views/rooms/RoomTile.tsx @@ -131,7 +131,7 @@ export default class RoomTile extends React.PureComponent { } private get showMessagePreview(): boolean { - return !this.props.isMinimized && this.props.showMessagePreview; + return this.props.showMessagePreview; } public componentDidUpdate(prevProps: Readonly, prevState: Readonly) { From 54e139a6adc7604411f041912ec5b97fb4903dba Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Mon, 3 May 2021 22:02:33 +0530 Subject: [PATCH 2/3] Generate previews when the room tile is maximised --- src/components/structures/LeftPanel.tsx | 2 +- src/components/views/rooms/RoomList.tsx | 1 + src/components/views/rooms/RoomSublist.tsx | 4 +++- src/components/views/rooms/RoomTile.tsx | 16 +++++++++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) 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("middlePanelResizedNoisy", 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}); @@ -131,7 +142,7 @@ export default class RoomTile extends React.PureComponent { } private get showMessagePreview(): boolean { - return this.props.showMessagePreview; + return !this.props.isMinimized && this.props.showMessagePreview; } public componentDidUpdate(prevProps: Readonly, prevState: Readonly) { @@ -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("middlePanelResizedNoisy", this.onResize); + } ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate); defaultDispatcher.unregister(this.dispatcherRef); this.notificationState.off(NOTIFICATION_STATE_UPDATE, this.onNotificationUpdate); From 29aec4abdbeea85b9517bcb1b8b554c9bd4e1cad Mon Sep 17 00:00:00 2001 From: Jaiwanth Date: Tue, 4 May 2021 15:39:46 +0530 Subject: [PATCH 3/3] Use middlePanelResized instead of noisy --- src/components/views/rooms/RoomTile.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/RoomTile.tsx b/src/components/views/rooms/RoomTile.tsx index 108e0979cb..7303f36489 100644 --- a/src/components/views/rooms/RoomTile.tsx +++ b/src/components/views/rooms/RoomTile.tsx @@ -105,7 +105,7 @@ 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("middlePanelResizedNoisy", this.onResize); + this.props.resizeNotifier.on("middlePanelResized", this.onResize); } } @@ -207,7 +207,7 @@ export default class RoomTile extends React.PureComponent { this.props.room.off("Room.name", this.onRoomNameUpdate); } if (this.props.resizeNotifier) { - this.props.resizeNotifier.off("middlePanelResizedNoisy", this.onResize); + this.props.resizeNotifier.off("middlePanelResized", this.onResize); } ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate); defaultDispatcher.unregister(this.dispatcherRef);