Merge pull request #832 from andy-g/live_commit_update

Make live updates to the commits (repo controller) without needing to reload
This commit is contained in:
Brad Rydzewski 2015-01-26 22:40:46 -08:00
commit 350d056d34

View file

@ -13,7 +13,20 @@ angular.module('app').controller("RepoController", function($scope, $http, $rout
// display a toast message with the
// commit details, allowing the user to
// reload the page.
$scope.msg = item;
// Try find an existing commit for this SHA. If found, replace it
var sha_updated = $scope.commits.some(function(element, index) {
if (element.sha == item.commit.sha)
$scope.commits[index] = item.commit;
return element.sha == item.commit.sha;
});
// Add a build message if the SHA couldn't be found and the new build status is 'Started'
if ( ! sha_updated && item.commit.status == 'Started') {
// $scope.commits.unshift(item.commit);
$scope.msg = item;
}
$scope.$apply();
} else {
// we trigger a toast (or html5) notification so the