From b4e091baddc2ffc470ae2853688af2ba318036a6 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 9 May 2014 17:54:11 -0400 Subject: [PATCH] Fix the build view controller to always search for the build to update --- static/js/controllers.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/static/js/controllers.js b/static/js/controllers.js index e32c0797a..d9684cbdc 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -1021,7 +1021,6 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope $scope.currentParentEntry = null; $scope.currentBuild = build; - $scope.currentBuildIndex = index; if (opt_updateURL) { if (build) { @@ -1099,8 +1098,18 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope ApiService.getRepoBuildStatus(null, params, true).then(function(resp) { // Note: We use extend here rather than replacing as Angular is depending on the // root build object to remain the same object. - $.extend(true, $scope.builds[$scope.currentBuildIndex], resp); - var currentBuild = $scope.builds[$scope.currentBuildIndex]; + var matchingBuilds = $.grep($scope.builds, function(elem) { + return elem['id'] == resp['id'] + }); + + var currentBuild = matchingBuilds.length > 0 ? matchingBuilds[0] : null; + if (currentBuild) { + currentBuild = $.extend(true, currentBuild, resp); + } else { + currentBuild = resp; + $scope.builds.push(currentBuild); + } + checkPollTimer(); // Load the updated logs for the build.