diff --git a/src/components/views/right_panel/GroupHeaderButtons.js b/src/components/views/right_panel/GroupHeaderButtons.js index 1b8e6a4a46..ec14331ad2 100644 --- a/src/components/views/right_panel/GroupHeaderButtons.js +++ b/src/components/views/right_panel/GroupHeaderButtons.js @@ -23,6 +23,15 @@ import HeaderButton from './HeaderButton'; import HeaderButtons from './HeaderButtons'; import RightPanel from '../../structures/RightPanel'; +const GROUP_PHASES = [ + RightPanel.Phase.GroupMemberInfo, + RightPanel.Phase.GroupMemberList, +]; +const ROOM_PHASES = [ + RightPanel.Phase.GroupRoomList, + RightPanel.Phase.GroupRoomInfo, +]; + export default class GroupHeaderButtons extends HeaderButtons { constructor(props) { super(props, RightPanel.Phase.GroupMemberList); @@ -53,33 +62,24 @@ export default class GroupHeaderButtons extends HeaderButtons { } _onMembersClicked() { - this.togglePhase(RightPanel.Phase.GroupMemberList); + this.togglePhase(RightPanel.Phase.GroupMemberList, GROUP_PHASES); } _onRoomsClicked() { - this.togglePhase(RightPanel.Phase.GroupRoomList); + this.togglePhase(RightPanel.Phase.GroupRoomList, ROOM_PHASES); } renderButtons() { - const groupPhases = [ - RightPanel.Phase.GroupMemberInfo, - RightPanel.Phase.GroupMemberList, - ]; - const roomPhases = [ - RightPanel.Phase.GroupRoomList, - RightPanel.Phase.GroupRoomInfo, - ]; - return [ , , diff --git a/src/components/views/right_panel/HeaderButtons.js b/src/components/views/right_panel/HeaderButtons.js index fb124e8d3f..2fa9935ab8 100644 --- a/src/components/views/right_panel/HeaderButtons.js +++ b/src/components/views/right_panel/HeaderButtons.js @@ -60,8 +60,8 @@ export default class HeaderButtons extends React.Component { }, extras)); } - togglePhase(phase) { - if (this.state.phase === phase) { + togglePhase(phase, validPhases = [phase]) { + if (validPhases.includes(this.state.phase)) { dis.dispatch({ action: 'hide_right_panel', }); diff --git a/src/components/views/right_panel/RoomHeaderButtons.js b/src/components/views/right_panel/RoomHeaderButtons.js index 65d74c7a0b..950fa30e38 100644 --- a/src/components/views/right_panel/RoomHeaderButtons.js +++ b/src/components/views/right_panel/RoomHeaderButtons.js @@ -23,6 +23,12 @@ import HeaderButton from './HeaderButton'; import HeaderButtons from './HeaderButtons'; import RightPanel from '../../structures/RightPanel'; +const MEMBER_PHASES = [ + RightPanel.Phase.RoomMemberList, + RightPanel.Phase.RoomMemberInfo, + RightPanel.Phase.Room3pidMemberInfo, +]; + export default class RoomHeaderButtons extends HeaderButtons { constructor(props) { super(props, RightPanel.Phase.RoomMemberList); @@ -51,7 +57,7 @@ export default class RoomHeaderButtons extends HeaderButtons { } _onMembersClicked() { - this.togglePhase(RightPanel.Phase.RoomMemberList); + this.togglePhase(RightPanel.Phase.RoomMemberList, MEMBER_PHASES); } _onFilesClicked() { @@ -63,16 +69,10 @@ export default class RoomHeaderButtons extends HeaderButtons { } renderButtons() { - const membersPhases = [ - RightPanel.Phase.RoomMemberList, - RightPanel.Phase.RoomMemberInfo, - RightPanel.Phase.Room3pidMemberInfo, - ]; - return [ ,