From 072fdf1cb8c4895b1914fa44e054c06933a62dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Sat, 28 Aug 2021 15:06:48 +0200 Subject: [PATCH 1/2] Use disptacher so that https://github.com/matrix-org/matrix-react-sdk/pull/6691 has effect 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 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/components/structures/CallEventGrouper.ts b/src/components/structures/CallEventGrouper.ts index b48bb32efe..16f8d6c68d 100644 --- a/src/components/structures/CallEventGrouper.ts +++ b/src/components/structures/CallEventGrouper.ts @@ -108,24 +108,34 @@ export default class CallEventGrouper extends EventEmitter { return [...this.events][0].getContent().call_id; } + private get roomId(): string { + return [...this.events][0]?.getRoomId(); + } + private onSilencedCallsChanged = () => { const newState = CallHandler.sharedInstance().isCallSilenced(this.callId); this.emit(CallEventGrouperEvent.SilencedChanged, newState); }; public answerCall = () => { - this.call?.answer(); + defaultDispatcher.dispatch({ + action: 'answer', + room_id: this.roomId, + }); }; public rejectCall = () => { - this.call?.reject(); + defaultDispatcher.dispatch({ + action: 'reject', + room_id: this.roomId, + }); }; public callBack = () => { defaultDispatcher.dispatch({ action: 'place_call', type: this.isVoice ? CallType.Voice : CallType.Video, - room_id: [...this.events][0]?.getRoomId(), + room_id: this.roomId, }); }; From 367049bd086342207197bb519930c7915d9ccff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 2 Sep 2021 17:52:00 +0200 Subject: [PATCH 2/2] Improve typing 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/structures/CallEventGrouper.ts b/src/components/structures/CallEventGrouper.ts index 16f8d6c68d..a19392b8fc 100644 --- a/src/components/structures/CallEventGrouper.ts +++ b/src/components/structures/CallEventGrouper.ts @@ -104,11 +104,11 @@ export default class CallEventGrouper extends EventEmitter { return ![...this.events].some((event) => event.sender?.userId === MatrixClientPeg.get().getUserId()); } - private get callId(): string { - return [...this.events][0].getContent().call_id; + private get callId(): string | undefined { + return [...this.events][0]?.getContent()?.call_id; } - private get roomId(): string { + private get roomId(): string | undefined { return [...this.events][0]?.getRoomId(); }