@@ -19,11 +19,15 @@ limitations under the License.
1919/*
2020 * State vars:
2121 * this.state.call_state = the UI state of the call (see CallHandler)
22+ *
23+ * Props:
24+ * room (JS SDK Room)
2225 */
2326
2427var React = require ( 'react' ) ;
2528var dis = require ( "../../dispatcher" ) ;
2629var CallHandler = require ( "../../CallHandler" ) ;
30+ var ConferenceHandler = require ( "../../ConferenceHandler" ) ;
2731
2832module . exports = {
2933 propTypes : {
@@ -44,7 +48,7 @@ module.exports = {
4448 componentDidMount : function ( ) {
4549 this . dispatcherRef = dis . register ( this . onAction ) ;
4650 if ( this . props . room ) {
47- var call = CallHandler . getCall ( this . props . room . roomId ) ;
51+ var call = this . _getCall ( this . props . room . roomId ) ;
4852 var callState = call ? call . call_state : "ended" ;
4953 this . setState ( {
5054 call_state : callState
@@ -57,15 +61,12 @@ module.exports = {
5761 } ,
5862
5963 onAction : function ( payload ) {
60- // if we were given a room_id to track, don't handle anything else.
61- if ( payload . room_id && this . props . room &&
62- this . props . room . roomId !== payload . room_id ) {
64+ // don't filter out payloads for room IDs other than props.room because
65+ // we may be interested in the conf 1:1 room
66+ if ( payload . action !== 'call_state' || ! payload . room_id ) {
6367 return ;
6468 }
65- if ( payload . action !== 'call_state' ) {
66- return ;
67- }
68- var call = CallHandler . getCall ( payload . room_id ) ;
69+ var call = this . _getCall ( payload . room_id ) ;
6970 var callState = call ? call . call_state : "ended" ;
7071 this . setState ( {
7172 call_state : callState
@@ -87,9 +88,30 @@ module.exports = {
8788 } ) ;
8889 } ,
8990 onHangupClick : function ( ) {
91+ var call = this . _getCall ( this . props . room . roomId ) ;
92+ if ( ! call ) { return ; }
9093 dis . dispatch ( {
9194 action : 'hangup' ,
92- room_id : this . props . room . roomId
95+ // hangup the call for this room, which may not be the room in props
96+ // (e.g. conferences which will hangup the 1:1 room instead)
97+ room_id : call . roomId
9398 } ) ;
99+ } ,
100+
101+ _getCall : function ( roomId ) {
102+ var call = CallHandler . getCall ( roomId ) ;
103+ if ( ! call ) {
104+ // search for a conference 1:1 call
105+ var activeCall = CallHandler . getAnyActiveCall ( ) ;
106+ if ( activeCall && activeCall . confUserId ) {
107+ var thisRoomConfUserId = ConferenceHandler . getConferenceUserIdForRoom (
108+ roomId
109+ ) ;
110+ if ( thisRoomConfUserId === activeCall . confUserId ) {
111+ call = activeCall ;
112+ }
113+ }
114+ }
115+ return call ;
94116 }
95117} ;
0 commit comments