From 14a4da54f861f0bb02d4a27cb03edb02a6d609eb Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 15 Jul 2015 17:36:47 +0100 Subject: [PATCH] Wire up hangup/answer buttons. --- skins/base/views/molecules/RoomHeader.js | 40 +++++++++++++++++++----- src/controllers/molecules/RoomHeader.js | 28 +++++++++++++++-- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/skins/base/views/molecules/RoomHeader.js b/skins/base/views/molecules/RoomHeader.js index 95e27a062b..e64aee5387 100644 --- a/skins/base/views/molecules/RoomHeader.js +++ b/skins/base/views/molecules/RoomHeader.js @@ -30,6 +30,38 @@ module.exports = React.createClass({ var topic = this.props.room.currentState.getStateEvents('m.room.topic', ''); topic = topic ?
{ topic.getContent().topic }
: null; + var callButtons; + if (this.state) { + switch (this.state.callState) { + case "INBOUND": + callButtons = ( +
+
+ YUP +
+
+ NOPE +
+
+ ); + break; + case "OUTBOUND": + callButtons = ( +
+ BYEBYE +
+ ); + break; + case "IN_CALL": + callButtons = ( +
+ BYEBYE +
+ ); + break; + } + } + return (
@@ -49,13 +81,7 @@ module.exports = React.createClass({
- { - this.state && this.state.inCall ? -
- -
- : null - } + {callButtons}
diff --git a/src/controllers/molecules/RoomHeader.js b/src/controllers/molecules/RoomHeader.js index 29ddf70e6a..dde8cf4ef8 100644 --- a/src/controllers/molecules/RoomHeader.js +++ b/src/controllers/molecules/RoomHeader.js @@ -18,7 +18,7 @@ limitations under the License. /* * State vars: - * this.state.inCall = boolean + * this.state.callState = OUTBOUND|INBOUND|IN_CALL|NO_CALL */ var dis = require("../../dispatcher"); @@ -28,7 +28,7 @@ module.exports = { componentDidMount: function() { this.dispatcherRef = dis.register(this.onAction); this.setState({ - inCall: false + callState: "NO_CALL" }); }, @@ -45,8 +45,24 @@ module.exports = { if (payload.action !== 'call_state') { return; } + var call = CallHandler.getCall(payload.room_id); + var callState = 'NO_CALL'; + if (call && call.state !== 'ended') { + if (call.state === 'connected') { + callState = "IN_CALL"; + } + else if (call.direction === 'outbound') { + callState = "OUTBOUND"; + } + else if (call.direction === 'inbound') { + callState = "INBOUND"; + } + else { + console.error("Cannot determine call state."); + } + } this.setState({ - inCall: (CallHandler.getCall(payload.room_id) !== null) + callState: callState }); }, @@ -69,6 +85,12 @@ module.exports = { action: 'hangup', room_id: this.props.room.roomId }); + }, + onAnswerClick: function() { + dis.dispatch({ + action: 'answer', + room_id: this.props.room.roomId + }); } };