From f96e25d833d04cdfa2c3fb53e3b5560e392d86e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 1 Jun 2021 10:11:48 +0200 Subject: [PATCH] Simply use call states MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/components/structures/CallEventGrouper.ts | 16 ++-------------- src/components/views/messages/CallEvent.tsx | 7 ++++--- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/components/structures/CallEventGrouper.ts b/src/components/structures/CallEventGrouper.ts index 2c08d7b047..5184ddc1bb 100644 --- a/src/components/structures/CallEventGrouper.ts +++ b/src/components/structures/CallEventGrouper.ts @@ -21,16 +21,6 @@ import { CallEvent, CallState, MatrixCall } from "matrix-js-sdk/src/webrtc/call" import CallHandler from '../../CallHandler'; import { EventEmitter } from 'events'; -export enum CallEventGrouperState { - Incoming = "incoming", - Connecting = "connecting", - Connected = "connected", - Ringing = "ringing", - Missed = "missed", - Rejected = "rejected", - Ended = "ended", -} - export enum CallEventGrouperEvent { StateChanged = "state_changed", } @@ -38,7 +28,7 @@ export enum CallEventGrouperEvent { export default class CallEventGrouper extends EventEmitter { invite: MatrixEvent; call: MatrixCall; - state: CallEventGrouperState; + state: CallState; public answerCall = () => { this.call?.answer(); @@ -76,9 +66,7 @@ export default class CallEventGrouper extends EventEmitter { } private setCallState = () => { - if (this.call?.state === CallState.Ringing) { - this.state = CallEventGrouperState.Incoming; - } + this.state = this.call.state this.emit(CallEventGrouperEvent.StateChanged, this.state); } diff --git a/src/components/views/messages/CallEvent.tsx b/src/components/views/messages/CallEvent.tsx index 0806934420..c4126639a7 100644 --- a/src/components/views/messages/CallEvent.tsx +++ b/src/components/views/messages/CallEvent.tsx @@ -19,8 +19,9 @@ import React from 'react'; import { MatrixEvent } from "matrix-js-sdk/src/models/event"; import { _t } from '../../../languageHandler'; import MemberAvatar from '../avatars/MemberAvatar'; -import CallEventGrouper, { CallEventGrouperEvent, CallEventGrouperState } from '../../structures/CallEventGrouper'; +import CallEventGrouper, { CallEventGrouperEvent } from '../../structures/CallEventGrouper'; import FormButton from '../elements/FormButton'; +import { CallState } from 'matrix-js-sdk/src/webrtc/call'; interface IProps { mxEvent: MatrixEvent; @@ -28,7 +29,7 @@ interface IProps { } interface IState { - callState: CallEventGrouperState; + callState: CallState; } export default class CallEvent extends React.Component { @@ -57,7 +58,7 @@ export default class CallEvent extends React.Component { const sender = event.sender ? event.sender.name : event.getSender(); let content; - if (this.state.callState === CallEventGrouperState.Incoming) { + if (this.state.callState === CallState.Ringing) { content = (