Temporarily remove strict mode to fix the call

Strict mode was causing an issue with the call flow. This disables it
temporarily, it will be reworked in the future.

Other changes:

- In CallProvider, ask mediadevices permission after the call is
  connected
- In WebRtcProvider, add `iceconnectionstatechange` listener to set the
  connected status

Change-Id: Ic366775c717d403faabe9c5787a26bd5c805e006
diff --git a/client/src/contexts/WebRtcProvider.tsx b/client/src/contexts/WebRtcProvider.tsx
index a56efab..f87e1ff 100644
--- a/client/src/contexts/WebRtcProvider.tsx
+++ b/client/src/contexts/WebRtcProvider.tsx
@@ -86,9 +86,9 @@
         sdp,
       };
 
+      await webRtcConnection.setLocalDescription(new RTCSessionDescription(sdp));
       console.info('Sending WebRtcOffer', webRtcOffer);
       webSocket.send(WebSocketMessageType.WebRtcOffer, webRtcOffer);
-      await webRtcConnection.setLocalDescription(new RTCSessionDescription(sdp));
     },
     [webRtcConnection, webSocket, contactUri]
   );
@@ -123,15 +123,13 @@
         offerToReceiveAudio: true,
         offerToReceiveVideo: true,
       });
-      sendWebRtcAnswer(sdp);
       await webRtcConnection.setLocalDescription(new RTCSessionDescription(sdp));
-      setIsConnected(true);
+      sendWebRtcAnswer(sdp);
     };
 
     const webRtcAnswerListener = async (data: WebRtcSdp) => {
       console.info('Received event on WebRtcAnswer', data);
       await webRtcConnection.setRemoteDescription(new RTCSessionDescription(data.sdp));
-      setIsConnected(true);
     };
 
     const webRtcIceCandidateListener = async (data: WebRtcIceCandidate) => {
@@ -177,12 +175,20 @@
       setRemoteStreams(event.streams);
     };
 
+    const connectionStateChangeEventListener = () => {
+      setIsConnected(
+        webRtcConnection.iceConnectionState === 'completed' || webRtcConnection.iceConnectionState === 'connected'
+      );
+    };
+
     webRtcConnection.addEventListener('icecandidate', iceCandidateEventListener);
     webRtcConnection.addEventListener('track', trackEventListener);
+    webRtcConnection.addEventListener('iceconnectionstatechange', connectionStateChangeEventListener);
 
     return () => {
       webRtcConnection.removeEventListener('icecandidate', iceCandidateEventListener);
       webRtcConnection.removeEventListener('track', trackEventListener);
+      webRtcConnection.removeEventListener('iceconnectionstatechange', connectionStateChangeEventListener);
     };
   }, [webRtcConnection, webSocket, contactUri]);