From da71aa7254ddea90a2448219c1c5582ec25495b6 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 29 Oct 2013 18:56:56 -0400 Subject: [PATCH] Clear the timer that watches build status when the page is changed --- static/js/controllers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/static/js/controllers.js b/static/js/controllers.js index b83be8ca8..a74f606a7 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -336,13 +336,21 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim }); var startBuildInfoTimer = function(repo) { + if ($scope.interval) { return; } + getBuildInfo(repo); - setInterval(function() { + $scope.interval = setInterval(function() { var container = document.getElementById('build-status-container'); if (container != null && container.offsetWidth > 0) { $scope.$apply(function() { getBuildInfo(repo); }); } }, 2000); + + $scope.$on("$destroy", function() { + if ($scope.interval) { + clearInterval($scope.interval); + } + }); }; var getBuildInfo = function(repo) {