From a4ba1323b9ec543a7934df454a7e1b2b12bdd39f Mon Sep 17 00:00:00 2001 From: Arnab Chatterjee Date: Fri, 15 Sep 2023 15:44:15 +0530 Subject: [PATCH] fix: var name --- packages/restapi/src/lib/spaceV2/connect.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/restapi/src/lib/spaceV2/connect.ts b/packages/restapi/src/lib/spaceV2/connect.ts index da51cd4b0..3713280db 100644 --- a/packages/restapi/src/lib/spaceV2/connect.ts +++ b/packages/restapi/src/lib/spaceV2/connect.ts @@ -31,11 +31,11 @@ export async function connect( peerConnection?.on('error', (err: any) => { console.log('error in connect', err); - const incomingIndex = peerAddress + const pendingIndex = peerAddress ? getIncomingIndexFromAddress(this.data.pendingPeerStreams, peerAddress) : 0; - if (this.data.pendingPeerStreams[incomingIndex].retryCount >= 5) { + if (this.data.pendingPeerStreams[pendingIndex].retryCount >= 5) { console.log('Max retries exceeded, please try again.'); this.disconnect({ peerAddress: peerAddress @@ -47,7 +47,7 @@ export async function connect( // retrying in case of connection error this.request({ senderAddress: this.data.local.address, - recipientAddress: this.data.pendingPeerStreams[incomingIndex].address, + recipientAddress: this.data.pendingPeerStreams[pendingIndex].address, chatId: this.data.spaceInfo.spaceId, retry: true, }); @@ -58,10 +58,10 @@ export async function connect( // update space data this.setSpaceV2Data((oldSpaceData) => { return produce(oldSpaceData, (draft) => { - const incomingIndex = peerAddress + const pendingIndex = peerAddress ? getIncomingIndexFromAddress(oldSpaceData.pendingPeerStreams, peerAddress) : 0; - draft.pendingPeerStreams[incomingIndex].status = VideoCallStatus.CONNECTED; + draft.pendingPeerStreams[pendingIndex].status = VideoCallStatus.CONNECTED; }); }); } catch (err) {