From 0920f17009a91f9d9c2a65af3655b0bcbbde829e Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 13 Aug 2021 17:27:05 +0530 Subject: [PATCH] fix(ui) - assist check for video and audio --- .../AssistActions/AssistActions.tsx | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx b/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx index 8ac60e4ba..c596fcb1f 100644 --- a/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx +++ b/frontend/app/components/Assist/components/AssistActions/AssistActions.tsx @@ -40,22 +40,30 @@ function AssistActions({ toggleChatWindow, userId, calling, peerConnectionStatus toast.info(`Call was rejected.`); } - function onError() { - toast.error(`Something went wrong!`); + function onError(e) { + toast.error(e); } - function call() { + function onCallConnect(lStream) { + setLocalStream(lStream); + setEndCall(() => callPeer( + lStream, + setIncomeStream, + onClose.bind(null, lStream), + onReject, + onError + )); + } + + function call() { navigator.mediaDevices.getUserMedia({video:true, audio:true}) - .then(lStream => { - setLocalStream(lStream); - setEndCall(() => callPeer( - lStream, - setIncomeStream, - onClose.bind(null, lStream), - onReject, - onError - )); - }).catch(onError); + .then(onCallConnect).catch(error => { + onError(error) + + navigator.mediaDevices.getUserMedia({audio:true}) + .then(onCallConnect) + .catch(onError) + }); } const inCall = calling !== CallingState.False;