diff options
Diffstat (limited to 'apps/files/js')
-rw-r--r-- | apps/files/js/filelist.js | 7 | ||||
-rw-r--r-- | apps/files/js/files.js | 26 |
2 files changed, 26 insertions, 7 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 66b4a006f88..006bd1f4966 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -152,6 +152,9 @@ var FileList={ FileActions.display(tr.find('td.filename'), true); return tr; }, + getCurrentDirectory: function(){ + return $('#dir').val() || '/'; + }, /** * @brief Changes the current directory and reload the file list. * @param targetDir target directory (non URL encoded) @@ -224,6 +227,10 @@ var FileList={ return; } + // TODO: should rather return upload file size through + // the files list ajax call + Files.updateStorageStatistics(true); + if (result.data.permissions) { FileList.setDirectoryPermissions(result.data.permissions); } diff --git a/apps/files/js/files.js b/apps/files/js/files.js index a7aea0957bd..2947512ece5 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -2,16 +2,23 @@ Files={ // file space size sync _updateStorageStatistics: function() { Files._updateStorageStatisticsTimeout = null; - if (Files.updateStorageStatistics.running){ - return; + var currentDir = FileList.getCurrentDirectory(), + state = Files.updateStorageStatistics; + if (state.dir){ + if (state.dir === currentDir) { + return; + } + // cancel previous call, as it was for another dir + state.call.abort(); } - Files.updateStorageStatistics.running = true; - $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) { - Files.updateStorageStatistics.running = false; + state.dir = currentDir; + state.call = $.getJSON(OC.filePath('files','ajax','getstoragestats.php') + '?dir=' + encodeURIComponent(currentDir),function(response) { + state.dir = null; + state.call = null; Files.updateMaxUploadFilesize(response); }); }, - updateStorageStatistics: function() { + updateStorageStatistics: function(force) { if (!OC.currentUser) { return; } @@ -20,7 +27,12 @@ Files={ if (Files._updateStorageStatisticsTimeout) { clearTimeout(Files._updateStorageStatisticsTimeout); } - Files._updateStorageStatisticsTimeout = setTimeout(Files._updateStorageStatistics, 1000); + if (force) { + Files._updateStorageStatistics(); + } + else { + Files._updateStorageStatisticsTimeout = setTimeout(Files._updateStorageStatistics, 250); + } }, updateMaxUploadFilesize:function(response) { |