From e047b5e11e279f9a7e01df0da6934c4e3c1531dd Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Wed, 30 Oct 2013 13:55:44 -0400 Subject: [PATCH] Dispose of the existing image tree so that a new one can be drawn in its place --- static/js/controllers.js | 11 ++++++++--- static/js/graphing.js | 10 ++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/static/js/controllers.js b/static/js/controllers.js index 1ea6fd055..25745ff0e 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -402,11 +402,16 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim }; var listImages = function() { - if ($scope.imageHistory) { return; } - var imageFetch = Restangular.one('repository/' + namespace + '/' + name + '/image/'); imageFetch.get().then(function(resp) { $scope.imageHistory = resp.images; + + // Dispose of any existing tree. + if ($scope.tree) { + $scope.tree.dispose(); + } + + // Create the new tree. $scope.tree = new ImageHistoryTree(namespace, name, resp.images, $scope.getCommentFirstLine, $scope.getTimeSince); @@ -418,7 +423,7 @@ function RepoCtrl($scope, Restangular, $routeParams, $rootScope, $location, $tim } $($scope.tree).bind('tagChanged', function(e) { - $scope.$apply(function() { $scope.setTag(e.tag, true); }); + $scope.$apply(function() { $scope.setTag(e.tag, true); }); }); $($scope.tree).bind('imageChanged', function(e) { $scope.$apply(function() { $scope.setImage(e.image); }); diff --git a/static/js/graphing.js b/static/js/graphing.js index c38ee273e..88aedc5da 100644 --- a/static/js/graphing.js +++ b/static/js/graphing.js @@ -809,6 +809,16 @@ ImageFileChangeTree.prototype.notifyResized = function() { }; +/** + * Disposes of the tree. + */ +ImageFileChangeTree.prototype.dispose = function() { + var container = this.container_ ; + $('#' + container).removeOverscroll(); + document.getElememtById(container).innerHTML = ''; +}; + + /** * Draws the tree. */