From 7842953faf5368a47518bdb5aa5fd9d58ab0c893 Mon Sep 17 00:00:00 2001 From: Sergiu Toma Date: Wed, 22 Feb 2023 18:57:57 +0200 Subject: [PATCH] LH-276: Refactor consumer-resume --- app.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index dfdf39c..cf9ddee 100644 --- a/app.js +++ b/app.js @@ -409,13 +409,17 @@ peers.on('connection', async (socket) => { const callId = socketDetails[socket.id]; const isInitiatorValue = isInitiator(callId, socket.id); console.log(`[consumer-resume] callId: ${callId} | isInitiator: ${isInitiatorValue}`); - if (isInitiatorValue) { - videoCalls[callId].initiatorConsumerVideo && videoCalls[callId].initiatorConsumerVideo.resume(); - videoCalls[callId].initiatorConsumerAudio && videoCalls[callId].initiatorConsumerAudio.resume(); - } else { - videoCalls[callId].receiverConsumerVideo && videoCalls[callId].receiverConsumerVideo.resume(); - videoCalls[callId].receiverConsumerAudio && videoCalls[callId].receiverConsumerAudio.resume(); - } + + const consumerVideo = isInitiatorValue + ? videoCalls[callId].initiatorConsumerVideo + : videoCalls[callId].receiverConsumerVideo; + + const consumerAudio = isInitiatorValue + ? videoCalls[callId].initiatorConsumerAudio + : videoCalls[callId].receiverConsumerAudio; + + consumerVideo?.resume(); + consumerAudio?.resume(); } catch (error) { console.error( `[consumer-resume] | ERROR | callId: ${socketDetails[socket.id]} | isInitiator: ${isInitiator} | error: ${