mirror of https://github.com/vector-im/riot-web
Add declined state
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>pull/21833/head
parent
f63b6fc0a9
commit
f7087d5148
|
@ -25,6 +25,7 @@ import { CallErrorCode, CallState } from 'matrix-js-sdk/src/webrtc/call';
|
||||||
import InfoTooltip, { InfoTooltipKind } from '../elements/InfoTooltip';
|
import InfoTooltip, { InfoTooltipKind } from '../elements/InfoTooltip';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import AccessibleTooltipButton from '../elements/AccessibleTooltipButton';
|
import AccessibleTooltipButton from '../elements/AccessibleTooltipButton';
|
||||||
|
import { MatrixClientPeg } from '../../../MatrixClientPeg';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
mxEvent: MatrixEvent;
|
mxEvent: MatrixEvent;
|
||||||
|
@ -69,6 +70,18 @@ export default class CallEvent extends React.Component<IProps, IState> {
|
||||||
this.setState({ callState: newState });
|
this.setState({ callState: newState });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private renderCallBackButton(text: string): JSX.Element {
|
||||||
|
return (
|
||||||
|
<AccessibleButton
|
||||||
|
className="mx_CallEvent_content_button mx_CallEvent_content_button_callBack"
|
||||||
|
onClick={this.props.callEventGrouper.callBack}
|
||||||
|
kind="primary"
|
||||||
|
>
|
||||||
|
<span> { text } </span>
|
||||||
|
</AccessibleButton>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private renderContent(state: CallState | CustomCallState): JSX.Element {
|
private renderContent(state: CallState | CustomCallState): JSX.Element {
|
||||||
if (state === CallState.Ringing) {
|
if (state === CallState.Ringing) {
|
||||||
const silenceClass = classNames({
|
const silenceClass = classNames({
|
||||||
|
@ -103,8 +116,18 @@ export default class CallEvent extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
if (state === CallState.Ended) {
|
if (state === CallState.Ended) {
|
||||||
const hangupReason = this.props.callEventGrouper.hangupReason;
|
const hangupReason = this.props.callEventGrouper.hangupReason;
|
||||||
|
const gotRejected = this.props.callEventGrouper.gotRejected;
|
||||||
|
const rejectParty = this.props.callEventGrouper.rejectParty;
|
||||||
|
|
||||||
if ([CallErrorCode.UserHangup, "user hangup"].includes(hangupReason) || !hangupReason) {
|
if (gotRejected) {
|
||||||
|
const weDeclinedCall = MatrixClientPeg.get().getUserId() === rejectParty;
|
||||||
|
return (
|
||||||
|
<div className="mx_CallEvent_content">
|
||||||
|
{ weDeclinedCall ? _t("You declined this call") : _t("The other party declined this call") }
|
||||||
|
{ this.renderCallBackButton(weDeclinedCall ? _t("Call back") : _t("Call again")) }
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else if (([CallErrorCode.UserHangup, "user hangup"].includes(hangupReason) || !hangupReason)) {
|
||||||
// workaround for https://github.com/vector-im/element-web/issues/5178
|
// workaround for https://github.com/vector-im/element-web/issues/5178
|
||||||
// it seems Android randomly sets a reason of "user hangup" which is
|
// it seems Android randomly sets a reason of "user hangup" which is
|
||||||
// interpreted as an error code :(
|
// interpreted as an error code :(
|
||||||
|
@ -120,13 +143,7 @@ export default class CallEvent extends React.Component<IProps, IState> {
|
||||||
return (
|
return (
|
||||||
<div className="mx_CallEvent_content">
|
<div className="mx_CallEvent_content">
|
||||||
{ _t("The remote side didn't pick up") }
|
{ _t("The remote side didn't pick up") }
|
||||||
<AccessibleButton
|
{ this.renderCallBackButton(_t("Call again")) }
|
||||||
className="mx_CallEvent_content_button mx_CallEvent_content_button_callBack"
|
|
||||||
onClick={this.props.callEventGrouper.callBack}
|
|
||||||
kind="primary"
|
|
||||||
>
|
|
||||||
<span> { _t("Call again") } </span>
|
|
||||||
</AccessibleButton>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -174,13 +191,7 @@ export default class CallEvent extends React.Component<IProps, IState> {
|
||||||
return (
|
return (
|
||||||
<div className="mx_CallEvent_content">
|
<div className="mx_CallEvent_content">
|
||||||
{ _t("You missed this call") }
|
{ _t("You missed this call") }
|
||||||
<AccessibleButton
|
{ this.renderCallBackButton(_t("Call back")) }
|
||||||
className="mx_CallEvent_content_button mx_CallEvent_content_button_callBack"
|
|
||||||
onClick={this.props.callEventGrouper.callBack}
|
|
||||||
kind="primary"
|
|
||||||
>
|
|
||||||
<span> { _t("Call back") } </span>
|
|
||||||
</AccessibleButton>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue