2015-07-13 03:51:24 +03:00
|
|
|
/*
|
|
|
|
Copyright 2015 OpenMarket Ltd
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var React = require('react');
|
2015-11-09 18:44:08 +03:00
|
|
|
var DragDropContext = require('react-dnd').DragDropContext;
|
2015-11-10 02:13:46 +03:00
|
|
|
var HTML5Backend = require('react-dnd-html5-backend');
|
2015-09-22 20:49:04 +03:00
|
|
|
var sdk = require('matrix-react-sdk')
|
2015-10-11 15:54:38 +03:00
|
|
|
var dis = require('matrix-react-sdk/lib/dispatcher');
|
2015-07-13 03:51:24 +03:00
|
|
|
|
2015-11-04 03:19:37 +03:00
|
|
|
var CallHandler = require("matrix-react-sdk/lib/CallHandler");
|
|
|
|
|
2015-11-09 18:44:08 +03:00
|
|
|
var LeftPanel = React.createClass({
|
2015-07-13 03:51:24 +03:00
|
|
|
displayName: 'LeftPanel',
|
|
|
|
|
2015-11-04 03:19:37 +03:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
showCallElement: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
this.dispatcherRef = dis.register(this.onAction);
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillReceiveProps: function(newProps) {
|
|
|
|
this._recheckCallElement(newProps.selectedRoom);
|
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount: function() {
|
|
|
|
dis.unregister(this.dispatcherRef);
|
|
|
|
},
|
|
|
|
|
|
|
|
onAction: function(payload) {
|
|
|
|
switch (payload.action) {
|
|
|
|
// listen for call state changes to prod the render method, which
|
|
|
|
// may hide the global CallView if the call it is tracking is dead
|
|
|
|
case 'call_state':
|
|
|
|
this._recheckCallElement(this.props.selectedRoom);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_recheckCallElement: function(selectedRoomId) {
|
|
|
|
// if we aren't viewing a room with an ongoing call, but there is an
|
|
|
|
// active call, show the call element - we need to do this to make
|
|
|
|
// audio/video not crap out
|
|
|
|
var activeCall = CallHandler.getAnyActiveCall();
|
|
|
|
var callForRoom = CallHandler.getCallForRoom(selectedRoomId);
|
|
|
|
var showCall = (activeCall && !callForRoom);
|
|
|
|
this.setState({
|
|
|
|
showCallElement: showCall
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2015-10-11 04:09:14 +03:00
|
|
|
onHideClick: function() {
|
2015-10-11 15:54:38 +03:00
|
|
|
dis.dispatch({
|
|
|
|
action: 'hide_left_panel',
|
|
|
|
});
|
2015-10-11 04:09:14 +03:00
|
|
|
},
|
|
|
|
|
2015-11-08 15:14:10 +03:00
|
|
|
onCallViewClick: function() {
|
|
|
|
var call = CallHandler.getAnyActiveCall();
|
|
|
|
if (call) {
|
|
|
|
dis.dispatch({
|
|
|
|
action: 'view_room',
|
|
|
|
room_id: call.roomId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-07-13 03:51:24 +03:00
|
|
|
render: function() {
|
2015-09-22 20:49:04 +03:00
|
|
|
var RoomList = sdk.getComponent('organisms.RoomList');
|
|
|
|
var BottomLeftMenu = sdk.getComponent('molecules.BottomLeftMenu');
|
|
|
|
var IncomingCallBox = sdk.getComponent('molecules.voip.IncomingCallBox');
|
|
|
|
|
2015-10-11 04:09:14 +03:00
|
|
|
var collapseButton;
|
|
|
|
var classes = "mx_LeftPanel";
|
2015-10-11 15:54:38 +03:00
|
|
|
if (this.props.collapsed) {
|
2015-10-11 04:09:14 +03:00
|
|
|
classes += " collapsed";
|
|
|
|
}
|
|
|
|
else {
|
2015-10-30 21:23:08 +03:00
|
|
|
// Hide the collapse button until we work out how to display it in the new skin
|
|
|
|
// collapseButton = <img className="mx_LeftPanel_hideButton" onClick={ this.onHideClick } src="img/hide.png" width="12" height="20" alt="<"/>
|
2015-10-11 04:09:14 +03:00
|
|
|
}
|
|
|
|
|
2015-11-04 03:19:37 +03:00
|
|
|
var callPreview;
|
|
|
|
if (this.state.showCallElement) {
|
|
|
|
var CallView = sdk.getComponent('molecules.voip.CallView');
|
2015-11-08 15:14:10 +03:00
|
|
|
callPreview = <CallView className="mx_LeftPanel_callView" onClick={this.onCallViewClick} />
|
2015-11-04 03:19:37 +03:00
|
|
|
}
|
|
|
|
|
2015-07-13 03:51:24 +03:00
|
|
|
return (
|
2015-10-11 04:09:14 +03:00
|
|
|
<aside className={classes}>
|
|
|
|
{ collapseButton }
|
2015-07-16 18:32:11 +03:00
|
|
|
<IncomingCallBox />
|
2015-11-04 03:19:37 +03:00
|
|
|
{ callPreview }
|
2015-10-11 15:54:38 +03:00
|
|
|
<RoomList selectedRoom={this.props.selectedRoom} collapsed={this.props.collapsed}/>
|
2015-10-11 17:00:43 +03:00
|
|
|
<BottomLeftMenu collapsed={this.props.collapsed}/>
|
2015-08-10 17:17:15 +03:00
|
|
|
</aside>
|
2015-07-13 03:51:24 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-11-09 18:44:08 +03:00
|
|
|
module.exports = DragDropContext(HTML5Backend)(LeftPanel);
|