From dd3c53edace917b06c72f8c6f2b58795fbb24284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Tue, 3 Aug 2021 09:37:41 +0200 Subject: [PATCH] Extract weSentTheEvent into a variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- src/webrtc/callEventHandler.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/webrtc/callEventHandler.ts b/src/webrtc/callEventHandler.ts index ac42ae77e..873fd8193 100644 --- a/src/webrtc/callEventHandler.ts +++ b/src/webrtc/callEventHandler.ts @@ -131,11 +131,12 @@ export class CallEventHandler { private handleCallEvent(event: MatrixEvent) { const content = event.getContent(); const type = event.getType() as EventType; + const weSentTheEvent = event.getSender() === this.client.credentials.userId; let call = content.call_id ? this.calls.get(content.call_id) : undefined; //console.info("RECV %s content=%s", type, JSON.stringify(content)); if (type === EventType.CallInvite) { - if (event.getSender() === this.client.credentials.userId) { + if (weSentTheEvent) { return; // ignore invites you send } @@ -222,7 +223,7 @@ export class CallEventHandler { this.client.emit("Call.incoming", call); } } else if (type === EventType.CallCandidates) { - if (event.getSender() === this.client.credentials.userId) { + if (weSentTheEvent) { return; } if (!call) { @@ -266,7 +267,7 @@ export class CallEventHandler { switch (type) { case EventType.CallAnswer: - if (event.getSender() === this.client.credentials.userId) { + if (weSentTheEvent) { if (call.state === CallState.Ringing) { call.onAnsweredElsewhere(content); }