Skip to content

Commit

Permalink
open and close filelists when they are displayed, fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
lars committed Jun 15, 2014
1 parent 4e39895 commit 9e663c5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
31 changes: 19 additions & 12 deletions app/js/controllers/browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@
EiskaltApp.controller('BrowseCtrl', function ($scope, EiskaltRPC) {
EiskaltRPC.ShowLocalLists().success(function (filelists) {
$scope.filelists = filelists;
EiskaltRPC.ShowOpenedLists().success(function (openedFilelists) {
angular.forEach($scope.filelists, function (filelist) {
if (openedFilelists.indexOf(filelist) < 0) {
EiskaltRPC.OpenFileList(filelist);
}
});
});
});
});

EiskaltApp.controller('FileListCtrl', function ($scope, EiskaltRPC) {
EiskaltApp.controller('FileListCtrl', function ($scope, $timeout, EiskaltRPC) {
$scope.filelist = $scope.$parent.filelist;

$scope.tree = {}
$scope.treeData = [];
EiskaltRPC.LsDirInList('', $scope.filelist).success(function (data) {
$scope.treeData = data;

var waitForOpening = function() {
EiskaltRPC.LsDirInList('', $scope.filelist).success(function (data) {
if (data.length > 0) {
$scope.treeData = data;
} else {
// not ready, give it some time
$timeout(waitForOpening, 250);
}
});
}

// open on start
EiskaltRPC.OpenFileList($scope.filelist).success(waitForOpening);
// close on leave
$scope.$on("$destroy", function(event) {
EiskaltRPC.CloseFileList($scope.filelist);
});

$scope.handle = function(node) {
Expand Down Expand Up @@ -48,4 +55,4 @@ EiskaltApp.controller('BrowseDownloadCtrl', function ($scope, EiskaltRPC) {
}
});
};
});
});
13 changes: 1 addition & 12 deletions app/js/controllers/hubs.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,25 +62,14 @@ EiskaltApp.controller('HubCtrl', function ($scope, $interval, $localStorage, set
$scope.newChatMessage = '';
$scope.refreshChat();
});
}

$scope.getFilelist = function (nick) {
console.log('getFilelist', nick);
// close possible old opened filelist

// trigger filelist download
//EiskaltRPC.GetFileList($scope.hub.huburl, nick);
}
};
});

EiskaltApp.controller('UserCtrl', function ($scope, EiskaltRPC) {
$scope.downloading = false;

$scope.downloadFilelist = function (nick) {
EiskaltRPC.GetFileList($scope.hub.huburl, nick).success(function(status) {
EiskaltApp.ShowOpenedLists().success(function(data) {
console.log(data);
});
if (status == 0) {
$scope.downloading = true;
} else {
Expand Down

0 comments on commit 9e663c5

Please sign in to comment.