Skip to content

Commit 14a4da5

Browse files
committed
Wire up hangup/answer buttons.
1 parent 37c9c8f commit 14a4da5

2 files changed

Lines changed: 58 additions & 10 deletions

File tree

‎skins/base/views/molecules/RoomHeader.js‎

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,38 @@ module.exports = React.createClass({
3030
var topic = this.props.room.currentState.getStateEvents('m.room.topic', '');
3131
topic = topic ? <div className="mx_RoomHeader_topic">{ topic.getContent().topic }</div> : null;
3232

33+
var callButtons;
34+
if (this.state) {
35+
switch (this.state.callState) {
36+
case "INBOUND":
37+
callButtons = (
38+
<div>
39+
<div className="mx_RoomHeader_button" onClick={this.onAnswerClick}>
40+
YUP
41+
</div>
42+
<div className="mx_RoomHeader_button" onClick={this.onHangupClick}>
43+
NOPE
44+
</div>
45+
</div>
46+
);
47+
break;
48+
case "OUTBOUND":
49+
callButtons = (
50+
<div className="mx_RoomHeader_button" onClick={this.onHangupClick}>
51+
BYEBYE
52+
</div>
53+
);
54+
break;
55+
case "IN_CALL":
56+
callButtons = (
57+
<div className="mx_RoomHeader_button" onClick={this.onHangupClick}>
58+
BYEBYE
59+
</div>
60+
);
61+
break;
62+
}
63+
}
64+
3365
return (
3466
<div className="mx_RoomHeader">
3567
<div className="mx_RoomHeader_wrapper">
@@ -49,13 +81,7 @@ module.exports = React.createClass({
4981
<div className="mx_RoomHeader_button">
5082
<img src="img/search.png" width="32" height="32"/>
5183
</div>
52-
{
53-
this.state && this.state.inCall ?
54-
<div className="mx_RoomHeader_button" onClick={this.onHangupClick}>
55-
<img src="img/video.png" width="64" height="32"/>
56-
</div>
57-
: null
58-
}
84+
{callButtons}
5985
<div className="mx_RoomHeader_button" onClick={this.onVideoClick}>
6086
<img src="img/video.png" width="32" height="32"/>
6187
</div>

‎src/controllers/molecules/RoomHeader.js‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ limitations under the License.
1818

1919
/*
2020
* State vars:
21-
* this.state.inCall = boolean
21+
* this.state.callState = OUTBOUND|INBOUND|IN_CALL|NO_CALL
2222
*/
2323

2424
var dis = require("../../dispatcher");
@@ -28,7 +28,7 @@ module.exports = {
2828
componentDidMount: function() {
2929
this.dispatcherRef = dis.register(this.onAction);
3030
this.setState({
31-
inCall: false
31+
callState: "NO_CALL"
3232
});
3333
},
3434

@@ -45,8 +45,24 @@ module.exports = {
4545
if (payload.action !== 'call_state') {
4646
return;
4747
}
48+
var call = CallHandler.getCall(payload.room_id);
49+
var callState = 'NO_CALL';
50+
if (call && call.state !== 'ended') {
51+
if (call.state === 'connected') {
52+
callState = "IN_CALL";
53+
}
54+
else if (call.direction === 'outbound') {
55+
callState = "OUTBOUND";
56+
}
57+
else if (call.direction === 'inbound') {
58+
callState = "INBOUND";
59+
}
60+
else {
61+
console.error("Cannot determine call state.");
62+
}
63+
}
4864
this.setState({
49-
inCall: (CallHandler.getCall(payload.room_id) !== null)
65+
callState: callState
5066
});
5167
},
5268

@@ -69,6 +85,12 @@ module.exports = {
6985
action: 'hangup',
7086
room_id: this.props.room.roomId
7187
});
88+
},
89+
onAnswerClick: function() {
90+
dis.dispatch({
91+
action: 'answer',
92+
room_id: this.props.room.roomId
93+
});
7294
}
7395
};
7496

0 commit comments

Comments
 (0)