From bd599c96a3b8cd02120e43ecf29c260221b1d49f Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Thu, 23 Sep 2021 14:43:39 +0100 Subject: [PATCH 1/3] Add React lifecycle methods publicity and return types --- src/components/structures/RightPanel.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/structures/RightPanel.tsx b/src/components/structures/RightPanel.tsx index 32a875557c..a108f376bd 100644 --- a/src/components/structures/RightPanel.tsx +++ b/src/components/structures/RightPanel.tsx @@ -143,14 +143,14 @@ export default class RightPanel extends React.Component { return rps.roomPanelPhase; } - componentDidMount() { + public componentDidMount(): void { this.dispatcherRef = dis.register(this.onAction); const cli = this.context; cli.on("RoomState.members", this.onRoomStateMember); this.initGroupStore(this.props.groupId); } - componentWillUnmount() { + public componentWillUnmount(): void { dis.unregister(this.dispatcherRef); if (this.context) { this.context.removeListener("RoomState.members", this.onRoomStateMember); @@ -159,7 +159,7 @@ export default class RightPanel extends React.Component { } // TODO: [REACT-WARNING] Replace with appropriate lifecycle event - UNSAFE_componentWillReceiveProps(newProps) { // eslint-disable-line + public UNSAFE_componentWillReceiveProps(newProps: IProps): void { // eslint-disable-line if (newProps.groupId !== this.props.groupId) { this.unregisterGroupStore(); this.initGroupStore(newProps.groupId); From 070f279ae7746b211dca319dd9edf8c4f5ccf5c0 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Thu, 23 Sep 2021 14:44:03 +0100 Subject: [PATCH 2/3] Close thread view when changing room --- src/components/structures/RightPanel.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/structures/RightPanel.tsx b/src/components/structures/RightPanel.tsx index a108f376bd..be5ed52a78 100644 --- a/src/components/structures/RightPanel.tsx +++ b/src/components/structures/RightPanel.tsx @@ -54,6 +54,7 @@ import { throttle } from 'lodash'; import SpaceStore from "../../stores/SpaceStore"; import { RoomPermalinkCreator } from '../../utils/permalinks/Permalinks'; import { E2EStatus } from '../../utils/ShieldUtils'; +import { SetRightPanelPhasePayload } from '../../dispatcher/payloads/SetRightPanelPhasePayload'; interface IProps { room?: Room; // if showing panels for a given room, this is set @@ -196,6 +197,15 @@ export default class RightPanel extends React.Component { }; private onAction = (payload: ActionPayload) => { + const isChangingRoom = payload.action === 'view_room'; + const isViewingThread = this.state.phase === RightPanelPhases.ThreadView; + if (isChangingRoom && isViewingThread) { + dis.dispatch({ + action: Action.SetRightPanelPhase, + phase: RightPanelPhases.ThreadPanel, + }); + } + if (payload.action === Action.AfterRightPanelPhaseChange) { this.setState({ phase: payload.phase, From 82d685e410f118d318fcca35965e7717247ab654 Mon Sep 17 00:00:00 2001 From: Germain Souquet Date: Fri, 24 Sep 2021 11:06:07 +0100 Subject: [PATCH 3/3] Only switch to ThreadPanel when roomId changes --- src/components/structures/RightPanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/structures/RightPanel.tsx b/src/components/structures/RightPanel.tsx index be5ed52a78..f626bb67d9 100644 --- a/src/components/structures/RightPanel.tsx +++ b/src/components/structures/RightPanel.tsx @@ -197,7 +197,7 @@ export default class RightPanel extends React.Component { }; private onAction = (payload: ActionPayload) => { - const isChangingRoom = payload.action === 'view_room'; + const isChangingRoom = payload.action === 'view_room' && payload.room_id !== this.props.room.roomId; const isViewingThread = this.state.phase === RightPanelPhases.ThreadView; if (isChangingRoom && isViewingThread) { dis.dispatch({