diff --git a/static/js/directives/audiovideo.js b/static/js/directives/audiovideo.js index 1504f37c..5f28c032 100644 --- a/static/js/directives/audiovideo.js +++ b/static/js/directives/audiovideo.js @@ -215,30 +215,32 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/ mediaStream.webrtc.e.on("done", function() { - $scope.hasUsermedia = false; - $scope.isActive = false; - $scope.peersTalking = {}; - if (BigScreen.enabled) { - BigScreen.exit(); - } - _.delay(function() { - if ($scope.isActive) { - return; + $scope.$apply(function() { + $scope.hasUsermedia = false; + $scope.isActive = false; + $scope.peersTalking = {}; + if (BigScreen.enabled) { + BigScreen.exit(); } - $scope.localVideo.src = ''; - $scope.miniVideo.src = ''; - $($scope.remoteVideos).children(".remoteVideo").remove(); - }, 1500); - $($scope.mini).removeClass("visible"); - $scope.localVideo.style.opacity = 0; - $scope.remoteVideos.style.opacity = 0; - $element.removeClass('active'); - _.each(streams, function(scope, k) { - scope.$destroy(); - delete streams[k]; + _.delay(function() { + if ($scope.isActive) { + return; + } + $scope.localVideo.src = ''; + $scope.miniVideo.src = ''; + $($scope.remoteVideos).children(".remoteVideo").remove(); + }, 1500); + $($scope.mini).removeClass("visible"); + $scope.localVideo.style.opacity = 0; + $scope.remoteVideos.style.opacity = 0; + $element.removeClass('active'); + _.each(streams, function(scope, k) { + scope.$destroy(); + delete streams[k]; + }); + $scope.rendererName = $scope.defaultRendererName; + $scope.haveStreams = false; }); - $scope.rendererName = $scope.defaultRendererName; - $scope.haveStreams = false; }); diff --git a/static/js/directives/buddylist.js b/static/js/directives/buddylist.js index 12102743..eb7b523f 100644 --- a/static/js/directives/buddylist.js +++ b/static/js/directives/buddylist.js @@ -42,7 +42,7 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) { }; webrtc.e.on("done", function() { - updateBuddyListVisibility(); + $scope.$apply(updateBuddyListVisibility); }); $scope.$on("room.joined", function(ev) { diff --git a/static/js/directives/presentation.js b/static/js/directives/presentation.js index 6e2534e5..770576c8 100644 --- a/static/js/directives/presentation.js +++ b/static/js/directives/presentation.js @@ -704,11 +704,13 @@ define(['jquery', 'underscore', 'text!partials/presentation.html', 'bigscreen'], }; mediaStream.webrtc.e.on("done", function() { - _.each($scope.availablePresentations, function(presentation) { - presentation.clear(); + $scope.$apply(function() { + _.each($scope.availablePresentations, function(presentation) { + presentation.clear(); + }); + $scope.availablePresentations = []; + $scope.activeDownloads = []; }); - $scope.availablePresentations = []; - $scope.activeDownloads = []; }); $(document).on("keyup", function(event) { diff --git a/static/js/directives/screenshare.js b/static/js/directives/screenshare.js index a4ece18a..8ffff71d 100644 --- a/static/js/directives/screenshare.js +++ b/static/js/directives/screenshare.js @@ -318,7 +318,7 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials }; mediaStream.webrtc.e.on("done", function() { - $scope.stopScreenshare(); + $scope.$apply($scope.stopScreenshare); }); $scope.$watch("layout.screenshare", function(newval, oldval) { diff --git a/static/js/mediastream/webrtc.js b/static/js/mediastream/webrtc.js index 3aed21c7..7b346397 100644 --- a/static/js/mediastream/webrtc.js +++ b/static/js/mediastream/webrtc.js @@ -608,17 +608,21 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u if (reason !== "receivedbye") { this.api.sendBye(id, reason); } - if (this.currentcall && currentcall) { - this.e.triggerHandler("statechange", ["connected", this.currentcall]); - } else { - this.e.triggerHandler("done", [reason]); - } + _.defer(_.bind(function() { + if (this.currentcall && currentcall) { + this.e.triggerHandler("statechange", ["connected", this.currentcall]); + } else { + this.e.triggerHandler("done", [reason]); + } + }, this)); return; } } if (this.currentcall) { id = this.currentcall.id; - this.e.triggerHandler("done", [reason]); + _.defer(_.bind(function() { + this.e.triggerHandler("done", [reason]); + }, this)); } this.stop(); if (id) {