From 4b256cab317ab02da549ce64a33911743f1b9d6f Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 6 Nov 2014 16:48:01 +0000 Subject: [PATCH] Don't cache isWebRTCSupported because whether webRTC is supported might change part-way through the page's lifecycle if your webrtc support comes from some kind of injected content script (hello OpenWebRTC Sarafi extension) --- syweb/webclient/components/matrix/matrix-call.js | 9 +++------ .../components/matrix/matrix-phone-service.js | 2 +- syweb/webclient/index.html | 2 +- syweb/webclient/room/room.html | 12 ++++++------ 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/syweb/webclient/components/matrix/matrix-call.js b/syweb/webclient/components/matrix/matrix-call.js index 465b2b7807..c13083298e 100644 --- a/syweb/webclient/components/matrix/matrix-call.js +++ b/syweb/webclient/components/matrix/matrix-call.js @@ -40,14 +40,11 @@ window.RTCPeerConnection = window.RTCPeerConnection || window.webkitRTCPeerConne window.RTCSessionDescription = window.RTCSessionDescription || window.webkitRTCSessionDescription || window.mozRTCSessionDescription; window.RTCIceCandidate = window.RTCIceCandidate || window.webkitRTCIceCandidate || window.mozRTCIceCandidate; -// Returns true if the browser supports all required features to make WebRTC call -var isWebRTCSupported = function () { - return !!(navigator.getUserMedia || window.RTCPeerConnection || window.RTCSessionDescription || window.RTCIceCandidate); -}; - angular.module('MatrixCall', []) .factory('MatrixCall', ['matrixService', 'matrixPhoneService', 'modelService', '$rootScope', '$timeout', function MatrixCallFactory(matrixService, matrixPhoneService, modelService, $rootScope, $timeout) { - $rootScope.isWebRTCSupported = isWebRTCSupported(); + $rootScope.isWebRTCSupported = function () { + return !!(navigator.getUserMedia || window.RTCPeerConnection || window.RTCSessionDescription || window.RTCIceCandidate); + }; var MatrixCall = function(room_id) { this.room_id = room_id; diff --git a/syweb/webclient/components/matrix/matrix-phone-service.js b/syweb/webclient/components/matrix/matrix-phone-service.js index 06465ed821..55dbbf522e 100644 --- a/syweb/webclient/components/matrix/matrix-phone-service.js +++ b/syweb/webclient/components/matrix/matrix-phone-service.js @@ -60,7 +60,7 @@ angular.module('matrixPhoneService', []) var MatrixCall = $injector.get('MatrixCall'); var call = new MatrixCall(event.room_id); - if (!isWebRTCSupported()) { + if (!$rootScope.isWebRTCSupported()) { console.log("Incoming call ID "+msg.call_id+" but this browser doesn't support WebRTC"); // don't hang up the call: there could be other clients connected that do support WebRTC and declining the // the call on their behalf would be really annoying. diff --git a/syweb/webclient/index.html b/syweb/webclient/index.html index 3ed968a5ea..992e8d3377 100644 --- a/syweb/webclient/index.html +++ b/syweb/webclient/index.html @@ -85,7 +85,7 @@ - + diff --git a/syweb/webclient/room/room.html b/syweb/webclient/room/room.html index ca5669a732..e59cc30edc 100644 --- a/syweb/webclient/room/room.html +++ b/syweb/webclient/room/room.html @@ -182,8 +182,8 @@ (msg.content.formatted_body | unsanitizedLinky) : (msg.content.msgtype === 'm.text' && msg.type === 'm.room.message') ? (msg.content.body | linky:'_blank') : '' "/> - Outgoing Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }} - Incoming Call{{ isWebRTCSupported ? '' : ' (But your browser does not support VoIP)' }} + Outgoing Call{{ isWebRTCSupported() ? '' : ' (But your browser does not support VoIP)' }} + Incoming Call{{ isWebRTCSupported() ? '' : ' (But your browser does not support VoIP)' }}
@@ -248,15 +248,15 @@