From 9cc57d2dd19828b7af702948c023baf675762349 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Sun, 1 Apr 2018 01:52:46 +0530 Subject: [PATCH] sendrecv/js: Fix some null/undefined checks --- webrtc/sendrecv/js/webrtc.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webrtc/sendrecv/js/webrtc.js b/webrtc/sendrecv/js/webrtc.js index 3c928ef26b..836203c9af 100644 --- a/webrtc/sendrecv/js/webrtc.js +++ b/webrtc/sendrecv/js/webrtc.js @@ -59,7 +59,8 @@ function setError(text) { function resetVideo() { // Release the webcam and mic - local_stream_promise.then(stream => { stream.stop(); }); + if (local_stream_promise) + local_stream_promise.then(stream => { stream.stop(); }); // Reset the video element and stop showing the last received frame var videoElement = getVideoElement(); @@ -125,7 +126,7 @@ function onServerMessage(event) { } // Incoming JSON signals the beginning of a call - if (peer_connection == null) + if (!peer_connection) createCall(msg); if (msg.sdp != null) { @@ -141,7 +142,7 @@ function onServerMessage(event) { function onServerClose(event) { resetVideo(); - if (peer_connection != null) { + if (peer_connection) { peer_connection.close(); peer_connection = null; }