11/*
2- Copyright 2015, 2016 OpenMarket Ltd
3- Copyright 2017, 2018 New Vector Ltd
4- Copyright 2020 The Matrix.org Foundation C.I.C.
2+ Copyright 2015-2018, 2020, 2021 The Matrix.org Foundation C.I.C.
53
64Licensed under the Apache License, Version 2.0 (the "License");
75you may not use this file except in compliance with the License.
@@ -19,7 +17,6 @@ import React, {createRef} from 'react';
1917import classNames from 'classnames' ;
2018import PropTypes from 'prop-types' ;
2119import { _t } from '../../../languageHandler' ;
22- import CallHandler from '../../../CallHandler' ;
2320import { MatrixClientPeg } from '../../../MatrixClientPeg' ;
2421import * as sdk from '../../../index' ;
2522import dis from '../../../dispatcher/dispatcher' ;
@@ -33,11 +30,8 @@ import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
3330import ReplyPreview from "./ReplyPreview" ;
3431import { UIFeature } from "../../../settings/UIFeature" ;
3532import WidgetStore from "../../../stores/WidgetStore" ;
36- import WidgetUtils from "../../../utils/WidgetUtils" ;
3733import { UPDATE_EVENT } from "../../../stores/AsyncStore" ;
3834import ActiveWidgetStore from "../../../stores/ActiveWidgetStore" ;
39- import { PlaceCallType } from "../../../CallHandler" ;
40- import { CallState } from 'matrix-js-sdk/src/webrtc/call' ;
4135
4236function ComposerAvatar ( props ) {
4337 const MemberStatusMessageAvatar = sdk . getComponent ( 'avatars.MemberStatusMessageAvatar' ) ;
@@ -50,97 +44,6 @@ ComposerAvatar.propTypes = {
5044 me : PropTypes . object . isRequired ,
5145} ;
5246
53- function CallButton ( props ) {
54- const onVoiceCallClick = ( ev ) => {
55- dis . dispatch ( {
56- action : 'place_call' ,
57- type : PlaceCallType . Voice ,
58- room_id : props . roomId ,
59- } ) ;
60- } ;
61-
62- return ( < AccessibleTooltipButton
63- className = "mx_MessageComposer_button mx_MessageComposer_voicecall"
64- onClick = { onVoiceCallClick }
65- title = { _t ( 'Voice call' ) }
66- /> ) ;
67- }
68-
69- CallButton . propTypes = {
70- roomId : PropTypes . string . isRequired ,
71- } ;
72-
73- function VideoCallButton ( props ) {
74- const onCallClick = ( ev ) => {
75- dis . dispatch ( {
76- action : 'place_call' ,
77- type : ev . shiftKey ? PlaceCallType . ScreenSharing : PlaceCallType . Video ,
78- room_id : props . roomId ,
79- } ) ;
80- } ;
81-
82- return < AccessibleTooltipButton
83- className = "mx_MessageComposer_button mx_MessageComposer_videocall"
84- onClick = { onCallClick }
85- title = { _t ( 'Video call' ) }
86- /> ;
87- }
88-
89- VideoCallButton . propTypes = {
90- roomId : PropTypes . string . isRequired ,
91- } ;
92-
93- function HangupButton ( props ) {
94- const onHangupClick = ( ) => {
95- if ( props . isConference ) {
96- dis . dispatch ( {
97- action : props . canEndConference ? 'end_conference' : 'hangup_conference' ,
98- room_id : props . roomId ,
99- } ) ;
100- return ;
101- }
102-
103- const call = CallHandler . sharedInstance ( ) . getCallForRoom ( props . roomId ) ;
104- if ( ! call ) {
105- return ;
106- }
107-
108- const action = call . state === CallState . Ringing ? 'reject' : 'hangup' ;
109-
110- dis . dispatch ( {
111- action,
112- // hangup the call for this room. NB. We use the room in props as the room ID
113- // as call.roomId may be the 'virtual room', and the dispatch actions always
114- // use the user-facing room (there was a time when we deliberately used
115- // call.roomId and *not* props.roomId, but that was for the old
116- // style Freeswitch conference calls and those times are gone.)
117- room_id : props . roomId ,
118- } ) ;
119- } ;
120-
121- let tooltip = _t ( "Hangup" ) ;
122- if ( props . isConference && props . canEndConference ) {
123- tooltip = _t ( "End conference" ) ;
124- }
125-
126- const canLeaveConference = ! props . isConference ? true : props . isInConference ;
127- return (
128- < AccessibleTooltipButton
129- className = "mx_MessageComposer_button mx_MessageComposer_hangup"
130- onClick = { onHangupClick }
131- title = { tooltip }
132- disabled = { ! canLeaveConference }
133- />
134- ) ;
135- }
136-
137- HangupButton . propTypes = {
138- roomId : PropTypes . string . isRequired ,
139- isConference : PropTypes . bool . isRequired ,
140- canEndConference : PropTypes . bool ,
141- isInConference : PropTypes . bool ,
142- } ;
143-
14447const EmojiButton = ( { addEmoji} ) => {
14548 const [ menuDisplayed , button , openMenu , closeMenu ] = useContextMenu ( ) ;
14649
@@ -265,7 +168,6 @@ export default class MessageComposer extends React.Component {
265168 this . state = {
266169 tombstone : this . _getRoomTombstone ( ) ,
267170 canSendMessages : this . props . room . maySendMessage ( ) ,
268- showCallButtons : SettingsStore . getValue ( "showCallButtonsInComposer" ) ,
269171 hasConference : WidgetStore . instance . doesRoomHaveConference ( this . props . room ) ,
270172 joinedConference : WidgetStore . instance . isJoinedToConferenceIn ( this . props . room ) ,
271173 } ;
@@ -405,12 +307,7 @@ export default class MessageComposer extends React.Component {
405307 ] ;
406308
407309 if ( ! this . state . tombstone && this . state . canSendMessages ) {
408- // This also currently includes the call buttons. Really we should
409- // check separately for whether we can call, but this is slightly
410- // complex because of conference calls.
411-
412310 const SendMessageComposer = sdk . getComponent ( "rooms.SendMessageComposer" ) ;
413- const callInProgress = this . props . callState && this . props . callState !== 'ended' ;
414311
415312 controls . push (
416313 < SendMessageComposer
@@ -430,30 +327,6 @@ export default class MessageComposer extends React.Component {
430327 SettingsStore . getValue ( "MessageComposerInput.showStickersButton" ) ) {
431328 controls . push ( < Stickerpicker key = "stickerpicker_controls_button" room = { this . props . room } /> ) ;
432329 }
433-
434- if ( this . state . showCallButtons ) {
435- if ( this . state . hasConference ) {
436- const canEndConf = WidgetUtils . canUserModifyWidgets ( this . props . room . roomId ) ;
437- controls . push (
438- < HangupButton
439- key = "controls_hangup"
440- roomId = { this . props . room . roomId }
441- isConference = { true }
442- canEndConference = { canEndConf }
443- isInConference = { this . state . joinedConference }
444- /> ,
445- ) ;
446- } else if ( callInProgress ) {
447- controls . push (
448- < HangupButton key = "controls_hangup" roomId = { this . props . room . roomId } isConference = { false } /> ,
449- ) ;
450- } else {
451- controls . push (
452- < CallButton key = "controls_call" roomId = { this . props . room . roomId } /> ,
453- < VideoCallButton key = "controls_videocall" roomId = { this . props . room . roomId } /> ,
454- ) ;
455- }
456- }
457330 } else if ( this . state . tombstone ) {
458331 const replacementRoomId = this . state . tombstone . getContent ( ) [ 'replacement_room' ] ;
459332
0 commit comments