From c632c72f25433a91cec974117fff05424ec774a7 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 28 Jan 2020 23:43:09 +0000 Subject: [PATCH] tidy up right-panel if-else-if statement --- src/components/structures/RightPanel.js | 133 +++++++++++++----------- 1 file changed, 75 insertions(+), 58 deletions(-) diff --git a/src/components/structures/RightPanel.js b/src/components/structures/RightPanel.js index 79955c8448..be10ead7ca 100644 --- a/src/components/structures/RightPanel.js +++ b/src/components/structures/RightPanel.js @@ -180,65 +180,82 @@ export default class RightPanel extends React.Component { let panel =
; - if (this.props.roomId && this.state.phase === RIGHT_PANEL_PHASES.RoomMemberList) { - panel = ; - } else if (this.props.groupId && this.state.phase === RIGHT_PANEL_PHASES.GroupMemberList) { - panel = ; - } else if (this.state.phase === RIGHT_PANEL_PHASES.GroupRoomList) { - panel = ; - } else if (this.state.phase === RIGHT_PANEL_PHASES.RoomMemberInfo || - this.state.phase === RIGHT_PANEL_PHASES.EncryptionPanel) { - if (SettingsStore.isFeatureEnabled("feature_cross_signing")) { - const onClose = () => { - dis.dispatch({ - action: "view_user", - member: this.state.phase === RIGHT_PANEL_PHASES.EncryptionPanel ? this.state.member : null, - }); - }; - panel = ; - } else { - panel = ; - } - } else if (this.state.phase === RIGHT_PANEL_PHASES.Room3pidMemberInfo) { - panel = ; - } else if (this.state.phase === RIGHT_PANEL_PHASES.GroupMemberInfo) { - if (SettingsStore.isFeatureEnabled("feature_cross_signing")) { - const onClose = () => { - dis.dispatch({ - action: "view_user", - member: null, - }); - }; - panel = ; - } else { - panel = ( - ; + } + break; + case RIGHT_PANEL_PHASES.GroupMemberList: + if (this.props.groupId) { + panel = ; + } + break; + case RIGHT_PANEL_PHASES.GroupRoomList: + panel = ; + break; + case RIGHT_PANEL_PHASES.RoomMemberInfo: + case RIGHT_PANEL_PHASES.EncryptionPanel: + if (SettingsStore.isFeatureEnabled("feature_cross_signing")) { + const onClose = () => { + dis.dispatch({ + action: "view_user", + member: this.state.phase === RIGHT_PANEL_PHASES.EncryptionPanel ? this.state.member : null, + }); + }; + panel = ; + } else { + panel = ; + } + break; + case RIGHT_PANEL_PHASES.Room3pidMemberInfo: + panel = ; + break; + case RIGHT_PANEL_PHASES.GroupMemberInfo: + if (SettingsStore.isFeatureEnabled("feature_cross_signing")) { + const onClose = () => { + dis.dispatch({ + action: "view_user", + member: null, + }); + }; + panel = - ); - } - } else if (this.state.phase === RIGHT_PANEL_PHASES.GroupRoomInfo) { - panel = ; - } else if (this.state.phase === RIGHT_PANEL_PHASES.NotificationPanel) { - panel = ; - } else if (this.state.phase === RIGHT_PANEL_PHASES.FilePanel) { - panel = ; + key={this.state.member.userId} + onClose={onClose} />; + } else { + panel = ( + + ); + } + break; + case RIGHT_PANEL_PHASES.GroupRoomInfo: + panel = ; + break; + case RIGHT_PANEL_PHASES.NotificationPanel: + panel = ; + break; + case RIGHT_PANEL_PHASES.FilePanel: + panel = ; + break; } const classes = classNames("mx_RightPanel", "mx_fadable", {