From 2cb817ae26a75fe97fa5f27e9e7438ea4bd17efa Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Dec 2018 15:33:28 +0100 Subject: [PATCH 1/6] remove dead code (collapse button was removed) --- src/components/views/rooms/RoomHeader.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 8aea31f9ed..996519445a 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -146,10 +146,6 @@ module.exports = React.createClass({ MatrixClientPeg.get().sendStateEvent(this.props.room.roomId, 'm.room.avatar', {url: null}, ''); }, - onShowRhsClick: function(ev) { - dis.dispatch({ action: 'show_right_panel' }); - }, - onShareRoomClick: function(ev) { const ShareDialog = sdk.getComponent("dialogs.ShareDialog"); Modal.createTrackedDialog('share room dialog', '', ShareDialog, { From a10f0a32672c8d011ae8a4f36bfd3f15329b0eee Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Dec 2018 15:33:45 +0100 Subject: [PATCH 2/6] don't open right panel when switching room again a view_right_panel_phase is dispatched by RoomHeaderButtons on view_room, which was triggering this to show the panel again. Check the fromHeader flag just like when hiding the panel so only room header buttons can hide or show the right panel --- src/components/views/right_panel/HeaderButtons.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/right_panel/HeaderButtons.js b/src/components/views/right_panel/HeaderButtons.js index 4ba0148652..18ec2bd941 100644 --- a/src/components/views/right_panel/HeaderButtons.js +++ b/src/components/views/right_panel/HeaderButtons.js @@ -59,7 +59,7 @@ export default class HeaderButtons extends React.Component { phase: null, }); } else { - if (this.props.collapsedRhs) { + if (this.props.collapsedRhs && payload.fromHeader) { dis.dispatch({ action: 'show_right_panel', }); From dafc54c434fbc24a395a9b2e75ca29f51d529c69 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Dec 2018 15:36:54 +0100 Subject: [PATCH 3/6] don't highlight room header buttons when right panel is collapsed --- .../views/right_panel/GroupHeaderButtons.js | 12 ++++++------ src/components/views/right_panel/HeaderButtons.js | 11 +++++++++++ .../views/right_panel/RoomHeaderButtons.js | 10 +++++----- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/components/views/right_panel/GroupHeaderButtons.js b/src/components/views/right_panel/GroupHeaderButtons.js index af54787b2c..6fcba1d815 100644 --- a/src/components/views/right_panel/GroupHeaderButtons.js +++ b/src/components/views/right_panel/GroupHeaderButtons.js @@ -55,23 +55,23 @@ export default class GroupHeaderButtons extends HeaderButtons { } renderButtons() { - const isPhaseGroup = [ + const groupPhases = [ RightPanel.Phase.GroupMemberInfo, RightPanel.Phase.GroupMemberList, - ].includes(this.state.phase); - const isPhaseRoom = [ + ]; + const roomPhases = [ RightPanel.Phase.GroupRoomList, RightPanel.Phase.GroupRoomInfo, - ].includes(this.state.phase); + ]; return [ , , diff --git a/src/components/views/right_panel/HeaderButtons.js b/src/components/views/right_panel/HeaderButtons.js index 18ec2bd941..3e3bbd3cd2 100644 --- a/src/components/views/right_panel/HeaderButtons.js +++ b/src/components/views/right_panel/HeaderButtons.js @@ -48,6 +48,17 @@ export default class HeaderButtons extends React.Component { }, extras)); } + isPhase(phases) { + if (this.props.collapsedRhs) { + return false; + } + if (Array.isArray(phases)) { + return phases.includes(this.state.phase); + } else { + return phases === this.state.phase; + } + } + onAction(payload) { if (payload.action === "view_right_panel_phase") { // only actions coming from header buttons should collapse the right panel diff --git a/src/components/views/right_panel/RoomHeaderButtons.js b/src/components/views/right_panel/RoomHeaderButtons.js index ba06bd9953..ff97fc5f4f 100644 --- a/src/components/views/right_panel/RoomHeaderButtons.js +++ b/src/components/views/right_panel/RoomHeaderButtons.js @@ -46,24 +46,24 @@ export default class RoomHeaderButtons extends HeaderButtons { } renderButtons() { - const isMembersPhase = [ + const membersPhases = [ RightPanel.Phase.RoomMemberList, RightPanel.Phase.RoomMemberInfo, - ].includes(this.state.phase); + ]; return [ , , , From 92c598dbcf4f287bc290e5a758b42c019391b055 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Dec 2018 15:38:15 +0100 Subject: [PATCH 4/6] remove group header expand right panel button --- src/components/structures/GroupView.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/components/structures/GroupView.js b/src/components/structures/GroupView.js index d77837ad63..478126db75 100644 --- a/src/components/structures/GroupView.js +++ b/src/components/structures/GroupView.js @@ -1272,15 +1272,6 @@ export default React.createClass({ , ); - if (this.props.collapsedRhs) { - rightButtons.push( - - - , - ); - } } const rightPanel = !this.props.collapsedRhs ? : undefined; From c0ab74d5f1cf32b96e7fc50f64c4c3df2d5968a3 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Dec 2018 16:27:17 +0100 Subject: [PATCH 5/6] reemit view_right_panel_phase when showing rhs, so right tab is active --- src/components/views/right_panel/HeaderButtons.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/views/right_panel/HeaderButtons.js b/src/components/views/right_panel/HeaderButtons.js index 3e3bbd3cd2..f0479eb8be 100644 --- a/src/components/views/right_panel/HeaderButtons.js +++ b/src/components/views/right_panel/HeaderButtons.js @@ -74,6 +74,11 @@ export default class HeaderButtons extends React.Component { dis.dispatch({ action: 'show_right_panel', }); + // emit payload again as the RightPanel didn't exist up + // till show_right_panel, just without the fromHeader flag + // as that would hide the right panel again + dis.dispatch(Object.assign({}, payload, {fromHeader: false})); + } this.setState({ phase: payload.phase, From 4b788fcb7e823b92feda4b6da94d7e29e17e8f8a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 18 Dec 2018 16:29:31 +0100 Subject: [PATCH 6/6] fix lint --- src/components/views/rooms/RoomHeader.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 996519445a..c7695cc4f7 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -23,7 +23,6 @@ import sdk from '../../../index'; import { _t } from '../../../languageHandler'; import MatrixClientPeg from '../../../MatrixClientPeg'; import Modal from "../../../Modal"; -import dis from "../../../dispatcher"; import RateLimitedFunc from '../../../ratelimitedfunc'; import * as linkify from 'linkifyjs';