mirror of
https://github.com/SchildiChat/element-web.git
synced 2024-10-01 01:26:12 -04:00
Wire up the "room" CallView for conferencing
This also separates out concerns better - UI elements just need to poke getCallForRoom rather than care if the thing they are displaying is a true 1:1 for this room ID or actually a conf room.
This commit is contained in:
parent
7866979c79
commit
353269370f
@ -80,7 +80,8 @@ module.exports = React.createClass({
|
|||||||
// active call, show the call element - we need to do this to make
|
// active call, show the call element - we need to do this to make
|
||||||
// audio/video not crap out
|
// audio/video not crap out
|
||||||
if (this.state.active_call && (
|
if (this.state.active_call && (
|
||||||
!this.state.currentRoom || !CallHandler.getCall(this.state.currentRoom))) {
|
!this.state.currentRoom ||
|
||||||
|
!CallHandler.getCallForRoom(this.state.currentRoom))) {
|
||||||
console.log(
|
console.log(
|
||||||
"Creating global CallView for active call in room %s",
|
"Creating global CallView for active call in room %s",
|
||||||
this.state.active_call.roomId
|
this.state.active_call.roomId
|
||||||
|
@ -58,6 +58,7 @@ var Modal = require("./Modal");
|
|||||||
var ComponentBroker = require('./ComponentBroker');
|
var ComponentBroker = require('./ComponentBroker');
|
||||||
var ErrorDialog = ComponentBroker.get("organisms/ErrorDialog");
|
var ErrorDialog = ComponentBroker.get("organisms/ErrorDialog");
|
||||||
var ConferenceCall = require("./ConferenceHandler").ConferenceCall;
|
var ConferenceCall = require("./ConferenceHandler").ConferenceCall;
|
||||||
|
var ConferenceHandler = require("./ConferenceHandler");
|
||||||
var Matrix = require("matrix-js-sdk");
|
var Matrix = require("matrix-js-sdk");
|
||||||
var dis = require("./dispatcher");
|
var dis = require("./dispatcher");
|
||||||
|
|
||||||
@ -241,10 +242,32 @@ dis.register(function(payload) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
|
getCallForRoom: function(roomId) {
|
||||||
|
return (
|
||||||
|
module.exports.getCall(roomId) ||
|
||||||
|
module.exports.getConferenceCall(roomId)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
getCall: function(roomId) {
|
getCall: function(roomId) {
|
||||||
return calls[roomId] || null;
|
return calls[roomId] || null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getConferenceCall: function(roomId) {
|
||||||
|
// search for a conference 1:1 call for this group chat room ID
|
||||||
|
var activeCall = module.exports.getAnyActiveCall();
|
||||||
|
if (activeCall && activeCall.confUserId) {
|
||||||
|
var thisRoomConfUserId = ConferenceHandler.getConferenceUserIdForRoom(
|
||||||
|
roomId
|
||||||
|
);
|
||||||
|
if (thisRoomConfUserId === activeCall.confUserId) {
|
||||||
|
return activeCall;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
|
||||||
getAnyActiveCall: function() {
|
getAnyActiveCall: function() {
|
||||||
var roomsWithCalls = Object.keys(calls);
|
var roomsWithCalls = Object.keys(calls);
|
||||||
for (var i = 0; i < roomsWithCalls.length; i++) {
|
for (var i = 0; i < roomsWithCalls.length; i++) {
|
||||||
|
@ -27,7 +27,6 @@ limitations under the License.
|
|||||||
var React = require('react');
|
var React = require('react');
|
||||||
var dis = require("../../dispatcher");
|
var dis = require("../../dispatcher");
|
||||||
var CallHandler = require("../../CallHandler");
|
var CallHandler = require("../../CallHandler");
|
||||||
var ConferenceHandler = require("../../ConferenceHandler");
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -48,7 +47,7 @@ module.exports = {
|
|||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this.dispatcherRef = dis.register(this.onAction);
|
this.dispatcherRef = dis.register(this.onAction);
|
||||||
if (this.props.room) {
|
if (this.props.room) {
|
||||||
var call = this._getCall(this.props.room.roomId);
|
var call = CallHandler.getCallForRoom(this.props.room.roomId);
|
||||||
var callState = call ? call.call_state : "ended";
|
var callState = call ? call.call_state : "ended";
|
||||||
this.setState({
|
this.setState({
|
||||||
call_state: callState
|
call_state: callState
|
||||||
@ -66,7 +65,7 @@ module.exports = {
|
|||||||
if (payload.action !== 'call_state' || !payload.room_id) {
|
if (payload.action !== 'call_state' || !payload.room_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var call = this._getCall(payload.room_id);
|
var call = CallHandler.getCallForRoom(payload.room_id);
|
||||||
var callState = call ? call.call_state : "ended";
|
var callState = call ? call.call_state : "ended";
|
||||||
this.setState({
|
this.setState({
|
||||||
call_state: callState
|
call_state: callState
|
||||||
@ -88,7 +87,7 @@ module.exports = {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onHangupClick: function() {
|
onHangupClick: function() {
|
||||||
var call = this._getCall(this.props.room.roomId);
|
var call = CallHandler.getCallForRoom(this.props.room.roomId);
|
||||||
if (!call) { return; }
|
if (!call) { return; }
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'hangup',
|
action: 'hangup',
|
||||||
@ -96,22 +95,5 @@ module.exports = {
|
|||||||
// (e.g. conferences which will hangup the 1:1 room instead)
|
// (e.g. conferences which will hangup the 1:1 room instead)
|
||||||
room_id: call.roomId
|
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;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -57,19 +57,16 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onAction: function(payload) {
|
onAction: function(payload) {
|
||||||
// if we were given a room_id to track, don't handle anything else.
|
// don't filter out payloads for room IDs other than props.room because
|
||||||
if (payload.room_id && this._trackedRoom &&
|
// we may be interested in the conf 1:1 room
|
||||||
this._trackedRoom.roomId !== payload.room_id) {
|
if (payload.action !== 'call_state' || !payload.room_id) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (payload.action !== 'call_state') {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.showCall(payload.room_id);
|
this.showCall(payload.room_id);
|
||||||
},
|
},
|
||||||
|
|
||||||
showCall: function(roomId) {
|
showCall: function(roomId) {
|
||||||
var call = CallHandler.getCall(roomId);
|
var call = CallHandler.getCallForRoom(roomId);
|
||||||
if (call) {
|
if (call) {
|
||||||
call.setLocalVideoElement(this.getVideoView().getLocalVideoElement());
|
call.setLocalVideoElement(this.getVideoView().getLocalVideoElement());
|
||||||
// N.B. the remote video element is used for playback for audio for voice calls
|
// N.B. the remote video element is used for playback for audio for voice calls
|
||||||
|
Loading…
Reference in New Issue
Block a user