mirror of https://github.com/vector-im/riot-web
Merge pull request #6086 from matrix-org/gsouquet/middle-pane-resize
commit
776b7100b5
|
@ -528,7 +528,6 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
||||||
tiles.push(<RoomTile
|
tiles.push(<RoomTile
|
||||||
room={room}
|
room={room}
|
||||||
key={`room-${room.roomId}`}
|
key={`room-${room.roomId}`}
|
||||||
resizeNotifier={this.props.resizeNotifier}
|
|
||||||
showMessagePreview={this.layout.showPreviews}
|
showMessagePreview={this.layout.showPreviews}
|
||||||
isMinimized={this.props.isMinimized}
|
isMinimized={this.props.isMinimized}
|
||||||
tag={this.props.tagId}
|
tag={this.props.tagId}
|
||||||
|
|
|
@ -53,14 +53,12 @@ import { CommunityPrototypeStore, IRoomProfile } from "../../../stores/Community
|
||||||
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import { getUnsentMessages } from "../../structures/RoomStatusBar";
|
import { getUnsentMessages } from "../../structures/RoomStatusBar";
|
||||||
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
|
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
|
||||||
import { ResizeNotifier } from "../../../utils/ResizeNotifier";
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
room: Room;
|
room: Room;
|
||||||
showMessagePreview: boolean;
|
showMessagePreview: boolean;
|
||||||
isMinimized: boolean;
|
isMinimized: boolean;
|
||||||
tag: TagID;
|
tag: TagID;
|
||||||
resizeNotifier: ResizeNotifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PartialDOMRect = Pick<DOMRect, "left" | "bottom">;
|
type PartialDOMRect = Pick<DOMRect, "left" | "bottom">;
|
||||||
|
@ -106,9 +104,6 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
|
|
||||||
this.notificationState = RoomNotificationStateStore.instance.getRoomState(this.props.room);
|
this.notificationState = RoomNotificationStateStore.instance.getRoomState(this.props.room);
|
||||||
this.roomProps = EchoChamber.forRoom(this.props.room);
|
this.roomProps = EchoChamber.forRoom(this.props.room);
|
||||||
if (this.props.resizeNotifier) {
|
|
||||||
this.props.resizeNotifier.on("middlePanelResized", this.onResize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private countUnsentEvents(): number {
|
private countUnsentEvents(): number {
|
||||||
|
@ -123,12 +118,6 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
this.forceUpdate(); // notification state changed - update
|
this.forceUpdate(); // notification state changed - update
|
||||||
};
|
};
|
||||||
|
|
||||||
private onResize = () => {
|
|
||||||
if (this.showMessagePreview && !this.state.messagePreview) {
|
|
||||||
this.generatePreview();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private onLocalEchoUpdated = (ev: MatrixEvent, room: Room) => {
|
private onLocalEchoUpdated = (ev: MatrixEvent, room: Room) => {
|
||||||
if (!room?.roomId === this.props.room.roomId) return;
|
if (!room?.roomId === this.props.room.roomId) return;
|
||||||
this.setState({hasUnsentEvents: this.countUnsentEvents() > 0});
|
this.setState({hasUnsentEvents: this.countUnsentEvents() > 0});
|
||||||
|
@ -148,7 +137,9 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>) {
|
public componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>) {
|
||||||
if (prevProps.showMessagePreview !== this.props.showMessagePreview && this.showMessagePreview) {
|
const showMessageChanged = prevProps.showMessagePreview !== this.props.showMessagePreview;
|
||||||
|
const minimizedChanged = prevProps.isMinimized !== this.props.isMinimized;
|
||||||
|
if (showMessageChanged || minimizedChanged) {
|
||||||
this.generatePreview();
|
this.generatePreview();
|
||||||
}
|
}
|
||||||
if (prevProps.room?.roomId !== this.props.room?.roomId) {
|
if (prevProps.room?.roomId !== this.props.room?.roomId) {
|
||||||
|
@ -208,9 +199,6 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
|
||||||
);
|
);
|
||||||
this.props.room.off("Room.name", this.onRoomNameUpdate);
|
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);
|
ActiveRoomObserver.removeListener(this.props.room.roomId, this.onActiveRoomUpdate);
|
||||||
defaultDispatcher.unregister(this.dispatcherRef);
|
defaultDispatcher.unregister(this.dispatcherRef);
|
||||||
this.notificationState.off(NOTIFICATION_STATE_UPDATE, this.onNotificationUpdate);
|
this.notificationState.off(NOTIFICATION_STATE_UPDATE, this.onNotificationUpdate);
|
||||||
|
|
Loading…
Reference in New Issue