Skip to content

Commit 6f174f8

Browse files
committed
Fixed event and scope order/update issues created by rooms service.
1 parent df30cbb commit 6f174f8

File tree

5 files changed

+42
-34
lines changed

5 files changed

+42
-34
lines changed

static/js/directives/audiovideo.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -215,30 +215,32 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/
215215

216216
mediaStream.webrtc.e.on("done", function() {
217217

218-
$scope.hasUsermedia = false;
219-
$scope.isActive = false;
220-
$scope.peersTalking = {};
221-
if (BigScreen.enabled) {
222-
BigScreen.exit();
223-
}
224-
_.delay(function() {
225-
if ($scope.isActive) {
226-
return;
218+
$scope.$apply(function() {
219+
$scope.hasUsermedia = false;
220+
$scope.isActive = false;
221+
$scope.peersTalking = {};
222+
if (BigScreen.enabled) {
223+
BigScreen.exit();
227224
}
228-
$scope.localVideo.src = '';
229-
$scope.miniVideo.src = '';
230-
$($scope.remoteVideos).children(".remoteVideo").remove();
231-
}, 1500);
232-
$($scope.mini).removeClass("visible");
233-
$scope.localVideo.style.opacity = 0;
234-
$scope.remoteVideos.style.opacity = 0;
235-
$element.removeClass('active');
236-
_.each(streams, function(scope, k) {
237-
scope.$destroy();
238-
delete streams[k];
225+
_.delay(function() {
226+
if ($scope.isActive) {
227+
return;
228+
}
229+
$scope.localVideo.src = '';
230+
$scope.miniVideo.src = '';
231+
$($scope.remoteVideos).children(".remoteVideo").remove();
232+
}, 1500);
233+
$($scope.mini).removeClass("visible");
234+
$scope.localVideo.style.opacity = 0;
235+
$scope.remoteVideos.style.opacity = 0;
236+
$element.removeClass('active');
237+
_.each(streams, function(scope, k) {
238+
scope.$destroy();
239+
delete streams[k];
240+
});
241+
$scope.rendererName = $scope.defaultRendererName;
242+
$scope.haveStreams = false;
239243
});
240-
$scope.rendererName = $scope.defaultRendererName;
241-
$scope.haveStreams = false;
242244

243245
});
244246

static/js/directives/buddylist.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) {
4242
};
4343

4444
webrtc.e.on("done", function() {
45-
updateBuddyListVisibility();
45+
$scope.$apply(updateBuddyListVisibility);
4646
});
4747

4848
$scope.$on("room.joined", function(ev) {

static/js/directives/presentation.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,13 @@ define(['jquery', 'underscore', 'text!partials/presentation.html', 'bigscreen'],
704704
};
705705

706706
mediaStream.webrtc.e.on("done", function() {
707-
_.each($scope.availablePresentations, function(presentation) {
708-
presentation.clear();
707+
$scope.$apply(function() {
708+
_.each($scope.availablePresentations, function(presentation) {
709+
presentation.clear();
710+
});
711+
$scope.availablePresentations = [];
712+
$scope.activeDownloads = [];
709713
});
710-
$scope.availablePresentations = [];
711-
$scope.activeDownloads = [];
712714
});
713715

714716
$(document).on("keyup", function(event) {

static/js/directives/screenshare.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials
318318
};
319319

320320
mediaStream.webrtc.e.on("done", function() {
321-
$scope.stopScreenshare();
321+
$scope.$apply($scope.stopScreenshare);
322322
});
323323

324324
$scope.$watch("layout.screenshare", function(newval, oldval) {

static/js/mediastream/webrtc.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -608,17 +608,21 @@ function($, _, PeerCall, PeerConference, PeerXfer, PeerScreenshare, UserMedia, u
608608
if (reason !== "receivedbye") {
609609
this.api.sendBye(id, reason);
610610
}
611-
if (this.currentcall && currentcall) {
612-
this.e.triggerHandler("statechange", ["connected", this.currentcall]);
613-
} else {
614-
this.e.triggerHandler("done", [reason]);
615-
}
611+
_.defer(_.bind(function() {
612+
if (this.currentcall && currentcall) {
613+
this.e.triggerHandler("statechange", ["connected", this.currentcall]);
614+
} else {
615+
this.e.triggerHandler("done", [reason]);
616+
}
617+
}, this));
616618
return;
617619
}
618620
}
619621
if (this.currentcall) {
620622
id = this.currentcall.id;
621-
this.e.triggerHandler("done", [reason]);
623+
_.defer(_.bind(function() {
624+
this.e.triggerHandler("done", [reason]);
625+
}, this));
622626
}
623627
this.stop();
624628
if (id) {

0 commit comments

Comments
 (0)