Merge pull request #181 from matrix-org/rav/issue_1049

Fix CallView in left panel
pull/21833/head
Richard van der Hoff 2016-02-29 17:51:39 +00:00
commit dc9a7e5e28
1 changed files with 21 additions and 13 deletions

View File

@ -23,8 +23,9 @@ module.exports = React.createClass({
displayName: 'CallView',
propTypes: {
// js-sdk room object
room: React.PropTypes.object.isRequired,
// js-sdk room object. If set, we will only show calls for the given
// room; if not, we will show any active call.
room: React.PropTypes.object,
// A Conference Handler implementation
// Must have a function signature:
@ -44,7 +45,7 @@ module.exports = React.createClass({
componentDidMount: function() {
this.dispatcherRef = dis.register(this.onAction);
this.showCall(this.props.room.roomId);
this.showCall();
},
componentWillUnmount: function() {
@ -54,20 +55,27 @@ module.exports = React.createClass({
onAction: function(payload) {
// 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) {
if (payload.action !== 'call_state') {
return;
}
this.showCall(payload.room_id);
this.showCall();
},
showCall: function(roomId) {
var call = (
CallHandler.getCallForRoom(roomId) ||
(this.props.ConferenceHandler ?
this.props.ConferenceHandler.getConferenceCallForRoom(roomId) :
null
)
);
showCall: function() {
var call;
if (this.props.room) {
var roomId = this.props.room.roomId;
call = CallHandler.getCallForRoom(roomId) ||
(this.props.ConferenceHandler ?
this.props.ConferenceHandler.getConferenceCallForRoom(roomId) :
null
);
}
else {
call = CallHandler.getAnyActiveCall();
}
if (call) {
call.setLocalVideoElement(this.getVideoView().getLocalVideoElement());
call.setRemoteVideoElement(this.getVideoView().getRemoteVideoElement());