From 6d29c1980443d7557a8b169c2d6c4a0a58e09dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 12 Jun 2021 16:32:01 +0200 Subject: [PATCH] Move call controls into a separate method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/voip/CallView.tsx | 160 +++++++++++++------------ 1 file changed, 83 insertions(+), 77 deletions(-) diff --git a/src/components/views/voip/CallView.tsx b/src/components/views/voip/CallView.tsx index ce2e4dabe9..5134425201 100644 --- a/src/components/views/voip/CallView.tsx +++ b/src/components/views/voip/CallView.tsx @@ -421,40 +421,14 @@ export default class CallView extends React.Component { this.props.call.transferToCall(transfereeCall); } - public render() { - const client = MatrixClientPeg.get(); - const callRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.call); - const secondaryCallRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.secondaryCall); - const callRoom = client.getRoom(callRoomId); - const secCallRoom = this.props.secondaryCall ? client.getRoom(secondaryCallRoomId) : null; - - let dialPad; - let contextMenu; - - if (this.state.showDialpad) { - dialPad = ; - } - - if (this.state.showMoreMenu) { - contextMenu = ; - } + private onHangupClick = () => { + dis.dispatch({ + action: 'hangup', + room_id: CallHandler.sharedInstance().roomIdForCall(this.props.call), + }); + } + private renderCallControls(): JSX.Element { const micClasses = classNames({ mx_CallView_callControls_button: true, mx_CallView_callControls_button_micOn: !this.state.micMuted, @@ -494,16 +468,22 @@ export default class CallView extends React.Component { mx_CallView_callControls_hidden: !this.state.controlsVisible, }); - const vidMuteButton = this.props.call.type === CallType.Video ? : null; + // We don't support call upgrades (yet) so hide the video mute button in voice calls + let vidMuteButton; + if (this.props.call.type === CallType.Video) { + vidMuteButton = ( + + ); + } - let screensharingButton; // Screensharing is possible, if we can send a second stream and // identify it using SDPStreamMetadata or if we can replace the already // existing usermedia track by a screensharing track. We also need to be // connected to know the state of the other side + let screensharingButton; if ( (this.props.call.opponentSupportsSDPStreamMetadata() || this.props.call.type === CallType.Video) && this.props.call.state === CallState.Connected @@ -532,39 +512,39 @@ export default class CallView extends React.Component { isExpanded={this.state.showMoreMenu} /> :
; - // in the near future, the dial pad button will go on the left. For now, it's the nothing button - // because something needs to have margin-right: auto to make the alignment correct. - const callControls =
- {dialpadButton} - - { - dis.dispatch({ - action: 'hangup', - room_id: callRoomId, - }); - }} - /> - {vidMuteButton} - {screensharingButton} -
-
- {contextMenuButton} -
; + return ( +
+ { dialpadButton } + + + { vidMuteButton } + { screensharingButton } +
+
+ { contextMenuButton } +
+ ); + } + public render() { + const client = MatrixClientPeg.get(); + const callRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.call); + const secondaryCallRoomId = CallHandler.sharedInstance().roomIdForCall(this.props.secondaryCall); + const callRoom = client.getRoom(callRoomId); + const secCallRoom = this.props.secondaryCall ? client.getRoom(secondaryCallRoomId) : null; const avatarSize = this.props.pipMode ? 76 : 160; - - // The 'content' for the call, ie. the videos for a video call and profile picture - // for voice calls (fills the bg) - let contentView: React.ReactNode; - const transfereeCall = CallHandler.sharedInstance().getTransfereeForCallId(this.props.call.callId); const isOnHold = this.state.isLocalOnHold || this.state.isRemoteOnHold; + + let contentView: React.ReactNode; let holdTransferContent; + if (transfereeCall) { const transferTargetRoom = MatrixClientPeg.get().getRoom( CallHandler.sharedInstance().roomIdForCall(this.props.call), @@ -638,9 +618,9 @@ export default class CallView extends React.Component { contentView = (
- {onHoldBackground} - {holdTransferContent} - {callControls} + { onHoldBackground } + { holdTransferContent } + { this.renderCallControls() }
); } else { @@ -664,8 +644,8 @@ export default class CallView extends React.Component { />
- {holdTransferContent} - {callControls} + { holdTransferContent } + { this.renderCallControls() }
); } @@ -700,7 +680,7 @@ export default class CallView extends React.Component {
{_t("Connecting")}
- {callControls} + { this.renderCallControls() } ); } else { @@ -739,7 +719,7 @@ export default class CallView extends React.Component { onResize={this.props.onResize} primary={true} /> - { callControls } + { this.renderCallControls() } ); } @@ -803,11 +783,37 @@ export default class CallView extends React.Component { myClassName = 'mx_CallView_pip'; } + let dialPad; + if (this.state.showDialpad) { + dialPad = ; + } + + let contextMenu; + if (this.state.showMoreMenu) { + contextMenu = ; + } + return
- {header} - {contentView} - {dialPad} - {contextMenu} + { header } + { contentView } + { dialPad } + { contextMenu }
; } }