2015-11-26 19:38:56 +03:00
|
|
|
/*
|
2016-01-07 07:06:39 +03:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2015-11-26 19:38:56 +03:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2017-07-01 16:58:46 +03:00
|
|
|
import React from 'react';
|
2017-12-26 04:03:18 +03:00
|
|
|
import PropTypes from 'prop-types';
|
2017-07-01 16:58:46 +03:00
|
|
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
|
|
|
import dis from '../../../dispatcher';
|
2017-06-08 14:33:29 +03:00
|
|
|
import { _t } from '../../../languageHandler';
|
2015-11-26 19:38:56 +03:00
|
|
|
|
|
|
|
module.exports = React.createClass({
|
|
|
|
displayName: 'IncomingCallBox',
|
|
|
|
|
2016-09-15 16:39:34 +03:00
|
|
|
propTypes: {
|
2017-12-26 04:03:18 +03:00
|
|
|
incomingCall: PropTypes.object,
|
2016-09-15 16:39:34 +03:00
|
|
|
},
|
|
|
|
|
2015-11-26 19:38:56 +03:00
|
|
|
onAnswerClick: function() {
|
|
|
|
dis.dispatch({
|
|
|
|
action: 'answer',
|
2017-07-01 16:58:46 +03:00
|
|
|
room_id: this.props.incomingCall.roomId,
|
2015-11-26 19:38:56 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
onRejectClick: function() {
|
|
|
|
dis.dispatch({
|
|
|
|
action: 'hangup',
|
2017-07-01 16:58:46 +03:00
|
|
|
room_id: this.props.incomingCall.roomId,
|
2015-11-26 19:38:56 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2017-07-01 16:58:46 +03:00
|
|
|
let room = null;
|
2016-09-15 16:39:34 +03:00
|
|
|
if (this.props.incomingCall) {
|
|
|
|
room = MatrixClientPeg.get().getRoom(this.props.incomingCall.roomId);
|
|
|
|
}
|
2015-11-26 19:38:56 +03:00
|
|
|
|
2017-07-01 16:58:46 +03:00
|
|
|
const caller = room ? room.name : _t("unknown caller");
|
2017-06-08 14:33:29 +03:00
|
|
|
|
|
|
|
let incomingCallText = null;
|
|
|
|
if (this.props.incomingCall) {
|
|
|
|
if (this.props.incomingCall.type === "voice") {
|
|
|
|
incomingCallText = _t("Incoming voice call from %(name)s", {name: caller});
|
2017-07-01 16:58:46 +03:00
|
|
|
} else if (this.props.incomingCall.type === "video") {
|
2017-06-08 14:33:29 +03:00
|
|
|
incomingCallText = _t("Incoming video call from %(name)s", {name: caller});
|
2017-07-01 16:58:46 +03:00
|
|
|
} else {
|
2017-06-08 14:33:29 +03:00
|
|
|
incomingCallText = _t("Incoming call from %(name)s", {name: caller});
|
|
|
|
}
|
|
|
|
}
|
2016-09-15 16:39:34 +03:00
|
|
|
|
2015-11-26 19:38:56 +03:00
|
|
|
return (
|
2015-12-17 05:49:09 +03:00
|
|
|
<div className="mx_IncomingCallBox" id="incomingCallBox">
|
2015-11-26 19:38:56 +03:00
|
|
|
<img className="mx_IncomingCallBox_chevron" src="img/chevron-left.png" width="9" height="16" />
|
|
|
|
<div className="mx_IncomingCallBox_title">
|
2017-09-28 13:21:06 +03:00
|
|
|
{ incomingCallText }
|
2015-11-26 19:38:56 +03:00
|
|
|
</div>
|
|
|
|
<div className="mx_IncomingCallBox_buttons">
|
|
|
|
<div className="mx_IncomingCallBox_buttons_cell">
|
|
|
|
<div className="mx_IncomingCallBox_buttons_decline" onClick={this.onRejectClick}>
|
2017-09-28 13:21:06 +03:00
|
|
|
{ _t("Decline") }
|
2015-11-26 19:38:56 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="mx_IncomingCallBox_buttons_cell">
|
|
|
|
<div className="mx_IncomingCallBox_buttons_accept" onClick={this.onAnswerClick}>
|
2017-09-28 13:21:06 +03:00
|
|
|
{ _t("Accept") }
|
2015-11-26 19:38:56 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2017-07-01 16:58:46 +03:00
|
|
|
},
|
2015-11-26 19:38:56 +03:00
|
|
|
});
|
|
|
|
|