Show/hide the Hangup button depending on the state of the conf call.
This commit is contained in:
parent
5e3698de64
commit
7866979c79
2 changed files with 44 additions and 14 deletions
|
@ -19,11 +19,15 @@ limitations under the License.
|
|||
/*
|
||||
* State vars:
|
||||
* this.state.call_state = the UI state of the call (see CallHandler)
|
||||
*
|
||||
* Props:
|
||||
* room (JS SDK Room)
|
||||
*/
|
||||
|
||||
var React = require('react');
|
||||
var dis = require("../../dispatcher");
|
||||
var CallHandler = require("../../CallHandler");
|
||||
var ConferenceHandler = require("../../ConferenceHandler");
|
||||
|
||||
module.exports = {
|
||||
propTypes: {
|
||||
|
@ -44,7 +48,7 @@ module.exports = {
|
|||
componentDidMount: function() {
|
||||
this.dispatcherRef = dis.register(this.onAction);
|
||||
if (this.props.room) {
|
||||
var call = CallHandler.getCall(this.props.room.roomId);
|
||||
var call = this._getCall(this.props.room.roomId);
|
||||
var callState = call ? call.call_state : "ended";
|
||||
this.setState({
|
||||
call_state: callState
|
||||
|
@ -57,15 +61,12 @@ module.exports = {
|
|||
},
|
||||
|
||||
onAction: function(payload) {
|
||||
// if we were given a room_id to track, don't handle anything else.
|
||||
if (payload.room_id && this.props.room &&
|
||||
this.props.room.roomId !== payload.room_id) {
|
||||
// don't filter out payloads for room IDs other than props.room because
|
||||
// we may be interested in the conf 1:1 room
|
||||
if (payload.action !== 'call_state' || !payload.room_id) {
|
||||
return;
|
||||
}
|
||||
if (payload.action !== 'call_state') {
|
||||
return;
|
||||
}
|
||||
var call = CallHandler.getCall(payload.room_id);
|
||||
var call = this._getCall(payload.room_id);
|
||||
var callState = call ? call.call_state : "ended";
|
||||
this.setState({
|
||||
call_state: callState
|
||||
|
@ -87,9 +88,30 @@ module.exports = {
|
|||
});
|
||||
},
|
||||
onHangupClick: function() {
|
||||
var call = this._getCall(this.props.room.roomId);
|
||||
if (!call) { return; }
|
||||
dis.dispatch({
|
||||
action: 'hangup',
|
||||
room_id: this.props.room.roomId
|
||||
// hangup the call for this room, which may not be the room in props
|
||||
// (e.g. conferences which will hangup the 1:1 room instead)
|
||||
room_id: call.roomId
|
||||
});
|
||||
},
|
||||
|
||||
_getCall: function(roomId) {
|
||||
var call = CallHandler.getCall(roomId);
|
||||
if (!call) {
|
||||
// search for a conference 1:1 call
|
||||
var activeCall = CallHandler.getAnyActiveCall();
|
||||
if (activeCall && activeCall.confUserId) {
|
||||
var thisRoomConfUserId = ConferenceHandler.getConferenceUserIdForRoom(
|
||||
roomId
|
||||
);
|
||||
if (thisRoomConfUserId === activeCall.confUserId) {
|
||||
call = activeCall;
|
||||
}
|
||||
}
|
||||
}
|
||||
return call;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue