Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 96592aa

Browse files
authored
Merge pull request #5948 from jaiwanth-v/room-preview-spaces
Generate room preview even when minimized
2 parents 28128ca + 29aec4a commit 96592aa

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

src/components/structures/LeftPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ export default class LeftPanel extends React.Component<IProps, IState> {
416416

417417
const roomList = <RoomList
418418
onKeyDown={this.onKeyDown}
419-
resizeNotifier={null}
419+
resizeNotifier={this.props.resizeNotifier}
420420
onFocus={this.onFocus}
421421
onBlur={this.onBlur}
422422
isMinimized={this.props.isMinimized}

src/components/views/rooms/RoomList.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
539539
onResize={this.props.onResize}
540540
showSkeleton={showSkeleton}
541541
extraTiles={extraTiles}
542+
resizeNotifier={this.props.resizeNotifier}
542543
alwaysVisible={ALWAYS_VISIBLE_TAGS.includes(orderedTagId)}
543544
/>
544545
});

src/components/views/rooms/RoomSublist.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import { ActionPayload } from "../../../dispatcher/payloads";
4444
import { Enable, Resizable } from "re-resizable";
4545
import { Direction } from "re-resizable/lib/resizer";
4646
import { polyfillTouchEvent } from "../../../@types/polyfill";
47+
import { ResizeNotifier } from "../../../utils/ResizeNotifier";
4748
import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore";
4849
import RoomListLayoutStore from "../../../stores/room-list/RoomListLayoutStore";
4950
import { arrayFastClone, arrayHasOrderChange } from "../../../utils/arrays";
@@ -75,7 +76,7 @@ interface IProps {
7576
onResize: () => void;
7677
showSkeleton?: boolean;
7778
alwaysVisible?: boolean;
78-
79+
resizeNotifier: ResizeNotifier;
7980
extraTiles?: ReactComponentElement<typeof ExtraTile>[];
8081

8182
// TODO: Account for https://github.com/vector-im/element-web/issues/14179
@@ -528,6 +529,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
528529
tiles.push(<RoomTile
529530
room={room}
530531
key={`room-${room.roomId}`}
532+
resizeNotifier={this.props.resizeNotifier}
531533
showMessagePreview={this.layout.showPreviews}
532534
isMinimized={this.props.isMinimized}
533535
tag={this.props.tagId}

src/components/views/rooms/RoomTile.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,14 @@ import { CommunityPrototypeStore, IRoomProfile } from "../../../stores/Community
5353
import { replaceableComponent } from "../../../utils/replaceableComponent";
5454
import { getUnsentMessages } from "../../structures/RoomStatusBar";
5555
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
56+
import { ResizeNotifier } from "../../../utils/ResizeNotifier";
5657

5758
interface IProps {
5859
room: Room;
5960
showMessagePreview: boolean;
6061
isMinimized: boolean;
6162
tag: TagID;
63+
resizeNotifier: ResizeNotifier;
6264
}
6365

6466
type PartialDOMRect = Pick<DOMRect, "left" | "bottom">;
@@ -102,6 +104,9 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
102104
};
103105
this.notificationState = RoomNotificationStateStore.instance.getRoomState(this.props.room);
104106
this.roomProps = EchoChamber.forRoom(this.props.room);
107+
if (this.props.resizeNotifier) {
108+
this.props.resizeNotifier.on("middlePanelResized", this.onResize);
109+
}
105110
}
106111

107112
private countUnsentEvents(): number {
@@ -116,6 +121,12 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
116121
this.forceUpdate(); // notification state changed - update
117122
};
118123

124+
private onResize = () => {
125+
if (this.showMessagePreview && !this.state.messagePreview) {
126+
this.setState({messagePreview: this.generatePreview()});
127+
}
128+
};
129+
119130
private onLocalEchoUpdated = (ev: MatrixEvent, room: Room) => {
120131
if (!room?.roomId === this.props.room.roomId) return;
121132
this.setState({hasUnsentEvents: this.countUnsentEvents() > 0});
@@ -195,6 +206,9 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
195206
);
196207
this.props.room.off("Room.name", this.onRoomNameUpdate);
197208
}
209+
if (this.props.resizeNotifier) {
210+
this.props.resizeNotifier.off("middlePanelResized", this.onResize);
211+
}
198212
ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate);
199213
defaultDispatcher.unregister(this.dispatcherRef);
200214
this.notificationState.off(NOTIFICATION_STATE_UPDATE, this.onNotificationUpdate);

0 commit comments

Comments
 (0)