Skip to content

Commit

Permalink
#394 ignore old operation results so we don't flicker the file exists…
Browse files Browse the repository at this point in the history
… issues
  • Loading branch information
jstrachan committed Jul 18, 2013
1 parent 4cc4119 commit 23de05a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions hawtio-web/src/main/webapp/app/wiki/js/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Wiki {
export function ViewController($scope, $location, $routeParams, $http, $timeout, workspace:Workspace, marked, fileExtensionTypeRegistry, wikiRepository:GitWikiRepository, $compile) {
Wiki.initScope($scope, $routeParams, $location);

$scope.operationCounter = 1;
$scope.addDialog = new Core.Dialog();
$scope.renameDialog = new Core.Dialog();
$scope.moveDialog = new Core.Dialog();
Expand Down Expand Up @@ -426,13 +427,19 @@ module Wiki {
}

function checkFileExists(path) {
$scope.operationCounter += 1;
var counter = $scope.operationCounter;
if (path) {
//console.log("Checking if the file " + path + " exists");
wikiRepository.exists($scope.branch, path, (result) => {
console.log("for path " + path + " got result " + result);
$scope.fileExists.exists = result ? true : false;
$scope.fileExists.name = result ? result.name : null;
Core.$apply($scope);
// filter old results
if ($scope.operationCounter === counter) {
console.log("for path " + path + " got result " + result);
$scope.fileExists.exists = result ? true : false;
$scope.fileExists.name = result ? result.name : null;
Core.$apply($scope);
} else {
console.log("Ignoring old results for " + path);
}
});
}
}
Expand Down

0 comments on commit 23de05a

Please sign in to comment.