From 3fe84249e597c50dad54eff9b8b3ccf50c529e00 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Wed, 21 Sep 2016 09:36:10 +0200 Subject: [PATCH] Highlight files and update storage stats at end of upload Properly trigger the "stop" even from the uploader. Also update storage stats at the end of all uploads instead of for each upload. --- apps/files/js/file-upload.js | 1 + apps/files/js/filelist.js | 2 +- apps/files/tests/js/filelistSpec.js | 17 +++++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 8c11794abb06..30eaa4445b32 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -1057,6 +1057,7 @@ OC.Uploader.prototype = _.extend({ self.clear(); self._hideProgressBar(); + self.trigger('stop', e, data); }); fileupload.on('fileuploadfail', function(e, data) { self.log('progress handle fileuploadfail', e, data); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index cdb6f86e6499..f3c9e1909b15 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -2769,8 +2769,8 @@ $.when.apply($, promises).then(function() { // highlight uploaded files self.highlightFiles(fileNames); + self.updateStorageStatistics(); }); - self.updateStorageStatistics(); var uploadText = self.$fileList.find('tr .uploadtext'); self.showFileBusyState(uploadText.closest('tr'), false); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 088b7a9ef472..1c270e48f217 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -2776,13 +2776,22 @@ describe('OCA.Files.FileList tests', function() { highlightStub.restore(); }); - it('queries storage stats', function() { + it('queries storage stats after all fetches are done', function() { var statStub = sinon.stub(fileList, 'updateStorageStatistics'); - addFile(createUpload('upload.txt', '/subdir')); - expect(statStub.notCalled).toEqual(true); + var highlightStub = sinon.stub(fileList, 'highlightFiles'); + var def1 = addFile(createUpload('upload.txt', '/subdir')); + var def2 = addFile(createUpload('upload2.txt', '/subdir')); + var def3 = addFile(createUpload('upload3.txt', '/another')); uploader.trigger('stop', {}); + + expect(statStub.notCalled).toEqual(true); + def1.resolve(); + expect(statStub.notCalled).toEqual(true); + def2.resolve(); + def3.resolve(); expect(statStub.calledOnce).toEqual(true); - statStub.restore(); + + highlightStub.restore(); }); }); });