Skip to content

Commit 3532693

Browse files
committed
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.
1 parent 7866979 commit 3532693

4 files changed

Lines changed: 32 additions & 29 deletions

File tree

‎skins/base/views/pages/MatrixChat.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ module.exports = React.createClass({
8080
// active call, show the call element - we need to do this to make
8181
// audio/video not crap out
8282
if (this.state.active_call && (
83-
!this.state.currentRoom || !CallHandler.getCall(this.state.currentRoom))) {
83+
!this.state.currentRoom ||
84+
!CallHandler.getCallForRoom(this.state.currentRoom))) {
8485
console.log(
8586
"Creating global CallView for active call in room %s",
8687
this.state.active_call.roomId

‎src/CallHandler.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var Modal = require("./Modal");
5858
var ComponentBroker = require('./ComponentBroker');
5959
var ErrorDialog = ComponentBroker.get("organisms/ErrorDialog");
6060
var ConferenceCall = require("./ConferenceHandler").ConferenceCall;
61+
var ConferenceHandler = require("./ConferenceHandler");
6162
var Matrix = require("matrix-js-sdk");
6263
var dis = require("./dispatcher");
6364

@@ -241,10 +242,32 @@ dis.register(function(payload) {
241242
});
242243

243244
module.exports = {
245+
246+
getCallForRoom: function(roomId) {
247+
return (
248+
module.exports.getCall(roomId) ||
249+
module.exports.getConferenceCall(roomId)
250+
);
251+
},
252+
244253
getCall: function(roomId) {
245254
return calls[roomId] || null;
246255
},
247256

257+
getConferenceCall: function(roomId) {
258+
// search for a conference 1:1 call for this group chat room ID
259+
var activeCall = module.exports.getAnyActiveCall();
260+
if (activeCall && activeCall.confUserId) {
261+
var thisRoomConfUserId = ConferenceHandler.getConferenceUserIdForRoom(
262+
roomId
263+
);
264+
if (thisRoomConfUserId === activeCall.confUserId) {
265+
return activeCall;
266+
}
267+
}
268+
return null;
269+
},
270+
248271
getAnyActiveCall: function() {
249272
var roomsWithCalls = Object.keys(calls);
250273
for (var i = 0; i < roomsWithCalls.length; i++) {

‎src/controllers/molecules/RoomHeader.js‎

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ limitations under the License.
2727
var React = require('react');
2828
var dis = require("../../dispatcher");
2929
var CallHandler = require("../../CallHandler");
30-
var ConferenceHandler = require("../../ConferenceHandler");
3130

3231
module.exports = {
3332
propTypes: {
@@ -48,7 +47,7 @@ module.exports = {
4847
componentDidMount: function() {
4948
this.dispatcherRef = dis.register(this.onAction);
5049
if (this.props.room) {
51-
var call = this._getCall(this.props.room.roomId);
50+
var call = CallHandler.getCallForRoom(this.props.room.roomId);
5251
var callState = call ? call.call_state : "ended";
5352
this.setState({
5453
call_state: callState
@@ -66,7 +65,7 @@ module.exports = {
6665
if (payload.action !== 'call_state' || !payload.room_id) {
6766
return;
6867
}
69-
var call = this._getCall(payload.room_id);
68+
var call = CallHandler.getCallForRoom(payload.room_id);
7069
var callState = call ? call.call_state : "ended";
7170
this.setState({
7271
call_state: callState
@@ -88,30 +87,13 @@ module.exports = {
8887
});
8988
},
9089
onHangupClick: function() {
91-
var call = this._getCall(this.props.room.roomId);
90+
var call = CallHandler.getCallForRoom(this.props.room.roomId);
9291
if (!call) { return; }
9392
dis.dispatch({
9493
action: 'hangup',
9594
// hangup the call for this room, which may not be the room in props
9695
// (e.g. conferences which will hangup the 1:1 room instead)
9796
room_id: call.roomId
9897
});
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;
11698
}
11799
};

‎src/controllers/molecules/voip/CallView.js‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,16 @@ module.exports = {
5757
},
5858

5959
onAction: function(payload) {
60-
// if we were given a room_id to track, don't handle anything else.
61-
if (payload.room_id && this._trackedRoom &&
62-
this._trackedRoom.roomId !== payload.room_id) {
63-
return;
64-
}
65-
if (payload.action !== 'call_state') {
60+
// don't filter out payloads for room IDs other than props.room because
61+
// we may be interested in the conf 1:1 room
62+
if (payload.action !== 'call_state' || !payload.room_id) {
6663
return;
6764
}
6865
this.showCall(payload.room_id);
6966
},
7067

7168
showCall: function(roomId) {
72-
var call = CallHandler.getCall(roomId);
69+
var call = CallHandler.getCallForRoom(roomId);
7370
if (call) {
7471
call.setLocalVideoElement(this.getVideoView().getLocalVideoElement());
7572
// N.B. the remote video element is used for playback for audio for voice calls

0 commit comments

Comments
 (0)