Clear the timer that watches build status when the page is changed

This commit is contained in:
Joseph Schorr 2013-10-29 18:56:56 -04:00
parent c91b40f356
commit da71aa7254

View file

@ -336,13 +336,21 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim
}); });
var startBuildInfoTimer = function(repo) { var startBuildInfoTimer = function(repo) {
if ($scope.interval) { return; }
getBuildInfo(repo); getBuildInfo(repo);
setInterval(function() { $scope.interval = setInterval(function() {
var container = document.getElementById('build-status-container'); var container = document.getElementById('build-status-container');
if (container != null && container.offsetWidth > 0) { if (container != null && container.offsetWidth > 0) {
$scope.$apply(function() { getBuildInfo(repo); }); $scope.$apply(function() { getBuildInfo(repo); });
} }
}, 2000); }, 2000);
$scope.$on("$destroy", function() {
if ($scope.interval) {
clearInterval($scope.interval);
}
});
}; };
var getBuildInfo = function(repo) { var getBuildInfo = function(repo) {