Skip to content

Commit 78bea91

Browse files
committed
Dispatch events when calls are made/received.
1 parent f94a061 commit 78bea91

5 files changed

Lines changed: 59 additions & 10 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ var React = require('react');
2020

2121
var MatrixClientPeg = require("../../../../src/MatrixClientPeg");
2222
var ComponentBroker = require('../../../../src/ComponentBroker');
23-
23+
var VideoViewController = require("../../../../src/controllers/molecules/VideoView");
2424
var VideoFeed = ComponentBroker.get('atoms/VideoFeed');
2525

2626
module.exports = React.createClass({
2727
displayName: 'VideoView',
28+
mixins: [VideoViewController],
2829

2930
getRemoteVideoElement: function() {
3031
return this.refs.remote.getDOMNode();
@@ -45,5 +46,5 @@ module.exports = React.createClass({
4546
</div>
4647
</div>
4748
);
48-
},
49+
}
4950
});

‎skins/base/views/organisms/RoomView.js‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ module.exports = React.createClass({
3737
displayName: 'RoomView',
3838
mixins: [RoomViewController],
3939

40-
getVideoView: function() {
41-
return this.refs.video;
42-
},
43-
4440
render: function() {
4541
var myUserId = MatrixClientPeg.get().credentials.userId;
4642
if (this.state.room.currentState.members[myUserId].membership == 'invite') {
@@ -73,7 +69,7 @@ module.exports = React.createClass({
7369
<div className="mx_RoomView">
7470
<RoomHeader room={this.state.room} />
7571
<div className="mx_RoomView_auxPanel">
76-
<VideoView ref="video" />
72+
<VideoView/>
7773
</div>
7874
<div ref="messageWrapper" className="mx_RoomView_messagePanel" onScroll={this.onMessageListScroll}>
7975
<div className="mx_RoomView_messageListWrapper">

‎src/controllers/molecules/RoomHeader.js‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ limitations under the License.
1616

1717
'use strict';
1818

19-
var MatrixClientPeg = require("../../MatrixClientPeg");
19+
var dis = require("../../dispatcher");
2020

2121
module.exports = {
2222
onVideoClick: function() {
23-
console.log("video clicked");
23+
dis.dispatch({
24+
action: 'place_call',
25+
type: "video",
26+
room_id: this.props.room.roomId
27+
});
2428
},
2529
onVoiceClick: function() {
26-
console.log("voice clicked");
30+
dis.dispatch({
31+
action: 'place_call',
32+
type: "voice",
33+
room_id: this.props.room.roomId
34+
});
2735
}
2836
};
2937

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright 2015 OpenMarket Ltd
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
'use strict';
18+
19+
var dis = require("../../dispatcher");
20+
21+
module.exports = {
22+
23+
componentDidMount: function() {
24+
this.dispatcherRef = dis.register(this.onAction);
25+
},
26+
27+
onAction: function(payload) {
28+
switch(payload.action) {
29+
case 'place_call':
30+
console.log("Place %s call in %s", payload.type, payload.room_id);
31+
break;
32+
case 'incoming_call':
33+
console.log("Incoming call: %s", payload.call);
34+
break;
35+
}
36+
}
37+
};
38+

‎src/controllers/pages/MatrixChat.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ module.exports = {
116116
that.setState({ready: true, currentRoom: firstRoom});
117117
dis.dispatch({action: 'focus_composer'});
118118
});
119+
cli.on('Call.incoming', function(call) {
120+
dis.dispatch({
121+
action: 'incoming_call',
122+
call: call
123+
});
124+
});
119125
Notifier.start();
120126
cli.startClient();
121127
},

0 commit comments

Comments
 (0)