summaryrefslogtreecommitdiffstats
path: root/apps/files/js/files.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/js/files.js')
-rw-r--r--apps/files/js/files.js55
1 files changed, 43 insertions, 12 deletions
diff --git a/apps/files/js/files.js b/apps/files/js/files.js
index eb30ddfda0f..2947512ece5 100644
--- a/apps/files/js/files.js
+++ b/apps/files/js/files.js
@@ -1,4 +1,40 @@
Files={
+ // file space size sync
+ _updateStorageStatistics: function() {
+ Files._updateStorageStatisticsTimeout = null;
+ 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();
+ }
+ 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(force) {
+ if (!OC.currentUser) {
+ return;
+ }
+
+ // debounce to prevent calling too often
+ if (Files._updateStorageStatisticsTimeout) {
+ clearTimeout(Files._updateStorageStatisticsTimeout);
+ }
+ if (force) {
+ Files._updateStorageStatistics();
+ }
+ else {
+ Files._updateStorageStatisticsTimeout = setTimeout(Files._updateStorageStatistics, 250);
+ }
+ },
+
updateMaxUploadFilesize:function(response) {
if (response === undefined) {
return;
@@ -351,29 +387,23 @@ $(document).ready(function() {
setTimeout ( "Files.displayStorageWarnings()", 100 );
OC.Notification.setDefault(Files.displayStorageWarnings);
- // file space size sync
- function update_storage_statistics() {
- $.getJSON(OC.filePath('files','ajax','getstoragestats.php'),function(response) {
- Files.updateMaxUploadFilesize(response);
- });
- }
// only possible at the moment if user is logged in
if (OC.currentUser) {
// start on load - we ask the server every 5 minutes
- var update_storage_statistics_interval = 5*60*1000;
- var update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval);
+ var updateStorageStatisticsInterval = 5*60*1000;
+ var updateStorageStatisticsIntervalId = setInterval(Files.updateStorageStatistics, updateStorageStatisticsInterval);
// Use jquery-visibility to de-/re-activate file stats sync
if ($.support.pageVisibility) {
$(document).on({
'show.visibility': function() {
- if (!update_storage_statistics_interval_id) {
- update_storage_statistics_interval_id = setInterval(update_storage_statistics, update_storage_statistics_interval);
+ if (!updateStorageStatisticsIntervalId) {
+ updateStorageStatisticsIntervalId = setInterval(Files.updateStorageStatistics, updateStorageStatisticsInterval);
}
},
'hide.visibility': function() {
- clearInterval(update_storage_statistics_interval_id);
- update_storage_statistics_interval_id = 0;
+ clearInterval(updateStorageStatisticsIntervalId);
+ updateStorageStatisticsIntervalId = 0;
}
});
}
@@ -417,6 +447,7 @@ function scanFiles(force, dir, users) {
scannerEventSource.listen('done',function(count) {
scanFiles.scanning=false;
console.log('done after ' + count + ' files');
+ Files.updateStorageStatistics();
});
scannerEventSource.listen('user',function(user) {
console.log('scanning files for ' + user);