Make sure all scope applies occur outside of the main digest loop

This commit is contained in:
Joseph Schorr 2014-07-10 16:38:41 -04:00
parent c7cc3f72f8
commit bebb02c800

View file

@ -432,9 +432,11 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
// If an error occurred, report it and done.
if (ping < 0) {
cached['pings'] = [-1];
$scope.$apply(function() {
callback(-1, false, -1);
});
setTimeout(function() {
$scope.$apply(function() {
callback(-1, false, -1);
});
}, 0);
return;
}
@ -447,9 +449,11 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
}
// Report the average ping.
$scope.$apply(function() {
callback(Math.floor(sum / cached['pings'].length), true, cached['pings'].length);
});
setTimeout(function() {
$scope.$apply(function() {
callback(Math.floor(sum / cached['pings'].length), true, cached['pings'].length);
});
}, 0);
// Schedule another check if we've done less than three.
if (cached['pings'].length < 3) {
@ -486,9 +490,11 @@ quayApp = angular.module('quay', quayDependencies, function($provide, cfpLoading
pingService.pingUrl = function($scope, url, callback) {
if (pingCache[url]) {
cached = pingCache[url];
$scope.$apply(function() {
callback(cached.result, cached.success);
});
setTimeout(function() {
$scope.$apply(function() {
callback(cached.result, cached.success);
});
}, 0);
return;
}