diff --git a/static/js/pages/repo-view.js b/static/js/pages/repo-view.js index 69f4b6af0..6e1099ba1 100644 --- a/static/js/pages/repo-view.js +++ b/static/js/pages/repo-view.js @@ -75,7 +75,7 @@ loadImages(); // Track builds. - buildPollChannel = AngularPollChannel.create($scope, loadRepositoryBuilds, 5000 /* 5s */); + buildPollChannel = AngularPollChannel.create($scope, loadRepositoryBuilds, 15000 /* 15s */); buildPollChannel.start(); }, 10); }); @@ -102,6 +102,26 @@ }; $scope.repositoryBuildsResource = ApiService.getRepoBuildsAsResource(params, /* background */true).get(function(resp) { + // Note: We could just set the builds here, but that causes a full digest cycle. Therefore, + // to be more efficient, we do some work here to determine if anything has changed since + // the last build load in the common case. + if ($scope.viewScope.builds && resp.builds.length == $scope.viewScope.builds.length) { + var hasNewInformation = false; + for (var i = 0; i < resp.builds.length; ++i) { + var current = $scope.viewScope.builds[i]; + var updated = resp.builds[i]; + if (current.phase != updated.phase || current.id != updated.id) { + hasNewInformation = true; + break; + } + } + + if (!hasNewInformation) { + callback(true); + return; + } + } + $scope.viewScope.builds = resp.builds; callback(true); }, errorHandler);