From b08b36c14f6d182f74b5bc758a83a5a6ba10d7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 22 May 2021 20:24:36 +0200 Subject: [PATCH] Add silencing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/views/voip/IncomingCallBox.tsx | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/components/views/voip/IncomingCallBox.tsx b/src/components/views/voip/IncomingCallBox.tsx index 2abdc0641d..a0660318bc 100644 --- a/src/components/views/voip/IncomingCallBox.tsx +++ b/src/components/views/voip/IncomingCallBox.tsx @@ -21,17 +21,20 @@ import {MatrixClientPeg} from '../../../MatrixClientPeg'; import dis from '../../../dispatcher/dispatcher'; import { _t } from '../../../languageHandler'; import { ActionPayload } from '../../../dispatcher/payloads'; -import CallHandler from '../../../CallHandler'; +import CallHandler, { AudioID } from '../../../CallHandler'; import RoomAvatar from '../avatars/RoomAvatar'; import FormButton from '../elements/FormButton'; import { CallState } from 'matrix-js-sdk/src/webrtc/call'; import {replaceableComponent} from "../../../utils/replaceableComponent"; +import AccessibleTooltipButton from '../elements/AccessibleTooltipButton'; +import classNames from 'classnames'; interface IProps { } interface IState { incomingCall: any; + silenced: boolean; } @replaceableComponent("views.voip.IncomingCallBox") @@ -44,6 +47,7 @@ export default class IncomingCallBox extends React.Component { this.dispatcherRef = dis.register(this.onAction); this.state = { incomingCall: null, + silenced: false, }; } @@ -58,6 +62,7 @@ export default class IncomingCallBox extends React.Component { if (call && call.state === CallState.Ringing) { this.setState({ incomingCall: call, + silenced: false, // Reset silenced state for new call }); } else { this.setState({ @@ -84,6 +89,13 @@ export default class IncomingCallBox extends React.Component { }); }; + private onSilenceClick: React.MouseEventHandler = (e) => { + e.stopPropagation(); + const newState = !this.state.silenced + this.setState({silenced: newState}); + newState ? CallHandler.sharedInstance().pause(AudioID.Ring) : CallHandler.sharedInstance().play(AudioID.Ring); + } + public render() { if (!this.state.incomingCall) { return null; @@ -107,6 +119,12 @@ export default class IncomingCallBox extends React.Component { } } + const silenceClass = classNames({ + "mx_IncomingCallBox_iconButton": true, + "mx_IncomingCallBox_unSilence": this.state.silenced, + "mx_IncomingCallBox_silence": !this.state.silenced, + }); + return
{

{caller}

{incomingCallText}

+