From 61c6bfe53cce0983262c880ff0a34e939c42ef25 Mon Sep 17 00:00:00 2001 From: Arnab Chatterjee Date: Fri, 15 Sep 2023 15:39:23 +0530 Subject: [PATCH] refactor: changed incoming to pending array --- packages/restapi/src/lib/spaceV2/connect.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/restapi/src/lib/spaceV2/connect.ts b/packages/restapi/src/lib/spaceV2/connect.ts index cc9ca1d22..da51cd4b0 100644 --- a/packages/restapi/src/lib/spaceV2/connect.ts +++ b/packages/restapi/src/lib/spaceV2/connect.ts @@ -25,29 +25,29 @@ export async function connect( try { const peerConnection = this.getPeerConnection( - peerAddress ? peerAddress : this.data.incomingPeerStreams[0].address + peerAddress ? peerAddress : this.data.pendingPeerStreams[0].address ) as any; peerConnection?.on('error', (err: any) => { console.log('error in connect', err); const incomingIndex = peerAddress - ? getIncomingIndexFromAddress(this.data.incomingPeerStreams, peerAddress) + ? getIncomingIndexFromAddress(this.data.pendingPeerStreams, peerAddress) : 0; - if (this.data.incomingPeerStreams[incomingIndex].retryCount >= 5) { + if (this.data.pendingPeerStreams[incomingIndex].retryCount >= 5) { console.log('Max retries exceeded, please try again.'); this.disconnect({ peerAddress: peerAddress ? peerAddress - : this.data.incomingPeerStreams[0].address, + : this.data.pendingPeerStreams[0].address, }); } // retrying in case of connection error this.request({ senderAddress: this.data.local.address, - recipientAddress: this.data.incomingPeerStreams[incomingIndex].address, + recipientAddress: this.data.pendingPeerStreams[incomingIndex].address, chatId: this.data.spaceInfo.spaceId, retry: true, }); @@ -59,9 +59,9 @@ export async function connect( this.setSpaceV2Data((oldSpaceData) => { return produce(oldSpaceData, (draft) => { const incomingIndex = peerAddress - ? getIncomingIndexFromAddress(oldSpaceData.incomingPeerStreams, peerAddress) + ? getIncomingIndexFromAddress(oldSpaceData.pendingPeerStreams, peerAddress) : 0; - draft.incomingPeerStreams[incomingIndex].status = VideoCallStatus.CONNECTED; + draft.pendingPeerStreams[incomingIndex].status = VideoCallStatus.CONNECTED; }); }); } catch (err) {