From b6f9ca0f9520075d7e59218ae7431842edc5cd5a Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 17 Jul 2015 14:25:41 +0100 Subject: [PATCH] When accepting calls, go to the right room. Relink video elements when CallView loads. --- src/CallHandler.js | 4 ++++ src/controllers/molecules/MessageComposer.js | 2 +- src/controllers/molecules/voip/CallView.js | 14 +++++++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/CallHandler.js b/src/CallHandler.js index 12b55c2659..418339325f 100644 --- a/src/CallHandler.js +++ b/src/CallHandler.js @@ -175,6 +175,10 @@ dis.register(function(payload) { } calls[payload.room_id].answer(); _setCallState(calls[payload.room_id], payload.room_id, "connected"); + dis.dispatch({ + action: "view_room", + room_id: payload.room_id + }); break; } }); diff --git a/src/controllers/molecules/MessageComposer.js b/src/controllers/molecules/MessageComposer.js index 34183083db..495041a1e9 100644 --- a/src/controllers/molecules/MessageComposer.js +++ b/src/controllers/molecules/MessageComposer.js @@ -30,7 +30,6 @@ var KeyCode = { module.exports = { componentWillMount: function() { - this.dispatcherRef = dis.register(this.onAction); this.tabStruct = { completing: false, original: null, @@ -126,6 +125,7 @@ module.exports = { }, componentDidMount: function() { + this.dispatcherRef = dis.register(this.onAction); this.sentHistory.init( this.refs.textarea.getDOMNode(), this.props.room.roomId diff --git a/src/controllers/molecules/voip/CallView.js b/src/controllers/molecules/voip/CallView.js index 485782e943..a4c090a36f 100644 --- a/src/controllers/molecules/voip/CallView.js +++ b/src/controllers/molecules/voip/CallView.js @@ -30,9 +30,9 @@ module.exports = { componentDidMount: function() { this.dispatcherRef = dis.register(this.onAction); - this.setState({ - call: null - }); + if (this.props.room) { + this.showCall(this.props.room.roomId); + } }, componentWillUnmount: function() { @@ -48,8 +48,12 @@ module.exports = { if (payload.action !== 'call_state') { return; } - var call = CallHandler.getCall(payload.room_id); - if (call && call.type === "video") { + this.showCall(payload.room_id); + }, + + showCall: function(roomId) { + var call = CallHandler.getCall(roomId); + if (call && call.type === "video" && call.state !== 'ended') { this.getVideoView().getLocalVideoElement().style.display = "initial"; this.getVideoView().getRemoteVideoElement().style.display = "initial"; call.setLocalVideoElement(this.getVideoView().getLocalVideoElement());