aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/js/files.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2013-11-06 10:55:19 +0100
committerVincent Petry <pvince81@owncloud.com>2013-11-06 10:55:19 +0100
commit31181e4348b9af2625cf4d6ad38cf4cd81db3c1f (patch)
treefc295013189c1c371b35c5080d85787b83f5b70a /apps/files/js/files.js
parent5d9ab6e7ac161a2431d9baca59281c03015b4ff5 (diff)
downloadnextcloud-server-31181e4348b9af2625cf4d6ad38cf4cd81db3c1f.tar.gz
nextcloud-server-31181e4348b9af2625cf4d6ad38cf4cd81db3c1f.zip
Fixed storage stats to be based on current directory
Previously, the storage statistics were always for the root dir. This means that the upload button would always show the limit for the root dir, even when uploading to a shared dir or external storage. This fix adds a "dir" argument to getstoragestats.php.
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r--apps/files/js/files.js26
1 files changed, 19 insertions, 7 deletions
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) {