Skip to content

Commit 7a50166

Browse files
committed
Move the 'thumbnail' video to the top-left of the screen
This was originally laid out at the MatrixChat level which could then be CSSified, but Matthew suggests this looks a lot better being at the RoomList level above recents. Move the rendering logic to RoomList.
1 parent 9c8b540 commit 7a50166

4 files changed

Lines changed: 39 additions & 27 deletions

File tree

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

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

1919
var React = require('react');
2020
var ComponentBroker = require('../../../../src/ComponentBroker');
21-
21+
var CallView = ComponentBroker.get('molecules/voip/CallView');
2222
var RoomDropTarget = ComponentBroker.get('molecules/RoomDropTarget');
2323

2424
var RoomListController = require("../../../../src/controllers/organisms/RoomList");
@@ -28,8 +28,14 @@ module.exports = React.createClass({
2828
mixins: [RoomListController],
2929

3030
render: function() {
31+
var callElement;
32+
if (this.state.show_call_element) {
33+
callElement = <CallView className="mx_MatrixChat_callView"/>
34+
}
35+
3136
return (
3237
<div className="mx_RoomList">
38+
{callElement}
3339
<h2 className="mx_RoomList_favourites_label">Favourites</h2>
3440
<RoomDropTarget text="Drop here to favourite"/>
3541

‎skins/base/views/pages/MatrixChat.js‎

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ limitations under the License.
1818

1919
var React = require('react');
2020
var ComponentBroker = require('../../../../src/ComponentBroker');
21-
var CallHandler = require('../../../../src/CallHandler');
2221

2322
var LeftPanel = ComponentBroker.get('organisms/LeftPanel');
2423
var RoomView = ComponentBroker.get('organisms/RoomView');
@@ -30,7 +29,6 @@ var CreateRoom = ComponentBroker.get('organisms/CreateRoom');
3029
var RoomDirectory = ComponentBroker.get('organisms/RoomDirectory');
3130
var MatrixToolbar = ComponentBroker.get('molecules/MatrixToolbar');
3231
var Notifier = ComponentBroker.get('organisms/Notifier');
33-
var CallView = ComponentBroker.get('molecules/voip/CallView');
3432

3533
var MatrixChatController = require('../../../../src/controllers/pages/MatrixChat');
3634

@@ -55,7 +53,7 @@ module.exports = React.createClass({
5553
render: function() {
5654
if (this.state.logged_in && this.state.ready) {
5755

58-
var page_element, call_element;
56+
var page_element;
5957
var right_panel = "";
6058

6159
switch (this.state.page_type) {
@@ -76,18 +74,6 @@ module.exports = React.createClass({
7674
right_panel = <RightPanel/>
7775
break;
7876
}
79-
// if we aren't viewing a room with an ongoing call, but there is an
80-
// active call, show the call element - we need to do this to make
81-
// audio/video not crap out
82-
if (this.state.active_call && (
83-
!this.state.currentRoom ||
84-
!CallHandler.getCallForRoom(this.state.currentRoom))) {
85-
console.log(
86-
"Creating global CallView for active call in room %s",
87-
this.state.active_call.roomId
88-
);
89-
call_element = <CallView className="mx_MatrixChat_callView"/>
90-
}
9177

9278
// TODO: Fix duplication here and do conditionals like we do above
9379
if (Notifier.supportsDesktopNotifications() && !Notifier.isEnabled() && !Notifier.isToolbarHidden()) {
@@ -96,7 +82,6 @@ module.exports = React.createClass({
9682
<MatrixToolbar />
9783
<div className="mx_MatrixChat mx_MatrixChat_toolbarShowing">
9884
<LeftPanel selectedRoom={this.state.currentRoom} />
99-
{call_element}
10085
<main className="mx_MatrixChat_middlePanel">
10186
{page_element}
10287
</main>
@@ -109,7 +94,6 @@ module.exports = React.createClass({
10994
return (
11095
<div className="mx_MatrixChat">
11196
<LeftPanel selectedRoom={this.state.currentRoom} />
112-
{call_element}
11397
<main className="mx_MatrixChat_middlePanel">
11498
{page_element}
11599
</main>

‎src/controllers/organisms/RoomList.js‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ limitations under the License.
1919
var React = require("react");
2020
var MatrixClientPeg = require("../../MatrixClientPeg");
2121
var RoomListSorter = require("../../RoomListSorter");
22+
var dis = require("../../dispatcher");
2223

2324
var ComponentBroker = require('../../ComponentBroker');
2425
var ConferenceHandler = require("../../ConferenceHandler");
26+
var CallHandler = require("../../CallHandler");
2527

2628
var RoomTile = ComponentBroker.get("molecules/RoomTile");
2729

@@ -41,7 +43,22 @@ module.exports = {
4143
});
4244
},
4345

46+
componentDidMount: function() {
47+
this.dispatcherRef = dis.register(this.onAction);
48+
},
49+
50+
onAction: function(payload) {
51+
switch (payload.action) {
52+
// listen for call state changes to prod the render method, which
53+
// may hide the global CallView if the call it is tracking is dead
54+
case 'call_state':
55+
this._recheckCallElement(this.props.selectedRoom);
56+
break;
57+
}
58+
},
59+
4460
componentWillUnmount: function() {
61+
dis.unregister(this.dispatcherRef);
4562
if (MatrixClientPeg.get()) {
4663
MatrixClientPeg.get().removeListener("Room", this.onRoom);
4764
MatrixClientPeg.get().removeListener("Room.timeline", this.onRoomTimeline);
@@ -51,6 +68,7 @@ module.exports = {
5168

5269
componentWillReceiveProps: function(newProps) {
5370
this.state.activityMap[newProps.selectedRoom] = undefined;
71+
this._recheckCallElement(newProps.selectedRoom);
5472
this.setState({
5573
activityMap: this.state.activityMap
5674
});
@@ -122,6 +140,18 @@ module.exports = {
122140
);
123141
},
124142

143+
_recheckCallElement: function(selectedRoomId) {
144+
// if we aren't viewing a room with an ongoing call, but there is an
145+
// active call, show the call element - we need to do this to make
146+
// audio/video not crap out
147+
var activeCall = CallHandler.getAnyActiveCall();
148+
var callForRoom = CallHandler.getCallForRoom(selectedRoomId);
149+
var showCall = (activeCall && !callForRoom);
150+
this.setState({
151+
show_call_element: showCall
152+
});
153+
},
154+
125155
makeRoomTiles: function() {
126156
var self = this;
127157
return this.state.roomList.map(function(room) {
@@ -136,5 +166,5 @@ module.exports = {
136166
/>
137167
);
138168
});
139-
},
169+
}
140170
};

‎src/controllers/pages/MatrixChat.js‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ var dis = require("../../dispatcher");
2626
var q = require("q");
2727

2828
var ComponentBroker = require('../../ComponentBroker');
29-
var CallHandler = require("../../CallHandler");
3029
var Notifier = ComponentBroker.get('organisms/Notifier');
3130
var MatrixTools = require('../../MatrixTools');
3231

@@ -206,13 +205,6 @@ module.exports = {
206205
case 'notifier_enabled':
207206
this.forceUpdate();
208207
break;
209-
case 'call_state':
210-
// listen for call state changes to prod the render method, which
211-
// may hide the global CallView if the call it is tracking is dead
212-
this.setState({
213-
active_call: CallHandler.getAnyActiveCall()
214-
});
215-
break;
216208
}
217209
},
218210

0 commit comments

Comments
 (0)