From 9d9c2720c29428efd8538a80bdce89f76eac81a3 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 9 Oct 2020 17:26:06 +0100 Subject: [PATCH] Hopefully make if statement clearer --- src/webrtc/callEventHandler.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/webrtc/callEventHandler.ts b/src/webrtc/callEventHandler.ts index 13797ea09..bf01f0a98 100644 --- a/src/webrtc/callEventHandler.ts +++ b/src/webrtc/callEventHandler.ts @@ -166,10 +166,15 @@ export class CallEventHandler { // Were we trying to call that user (room)? let existingCall; for (const thisCall of this.calls.values()) { - if (call.roomId === thisCall.roomId && - thisCall.direction === CallDirection.Outbound && - ([CallState.WaitLocalMedia, CallState.CreateOffer, CallState.InviteSent].indexOf( - thisCall.state) !== -1)) { + const isCalling = [CallState.WaitLocalMedia, CallState.CreateOffer, CallState.InviteSent].includes( + thisCall.state, + ); + + if ( + call.roomId === thisCall.roomId && + thisCall.direction === CallDirection.Outbound && + isCalling + ) { existingCall = thisCall; break; }