From 70fd09901bfa559321773dfba38d337eb88da4b1 Mon Sep 17 00:00:00 2001 From: noveens Date: Wed, 1 Mar 2017 17:27:48 +0530 Subject: [PATCH 1/7] filelist only refreshed if directory changes --- apps/files/js/filelist.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 3f1cdada2b95..ad236c936839 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1416,6 +1416,9 @@ if (!force && currentDir === targetDir) { return; } + if(this._currentDirectory && currentDir === targetDir) { + return; + } this._setCurrentDir(targetDir, changeUrl, fileId); // discard finished uploads list, we'll get it through a regular reload this._uploads = {}; From 8042534b46c491af29c3ee08850e8d29ec05d44e Mon Sep 17 00:00:00 2001 From: noveens Date: Wed, 1 Mar 2017 18:47:18 +0530 Subject: [PATCH 2/7] check introduced at another method --- apps/files/js/filelist.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index ad236c936839..b2d26ba3c807 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -549,6 +549,10 @@ */ _onUrlChanged: function(e) { if (e && _.isString(e.dir)) { + var currentDir = this.getCurrentDirectory(); + if(this._currentDirectory && currentDir === e.dir) { + return; + } this.changeDirectory(e.dir, false, true); } }, @@ -1416,9 +1420,6 @@ if (!force && currentDir === targetDir) { return; } - if(this._currentDirectory && currentDir === targetDir) { - return; - } this._setCurrentDir(targetDir, changeUrl, fileId); // discard finished uploads list, we'll get it through a regular reload this._uploads = {}; From 780c35ccae9aedf18a3a6783fdcc3e26770b6ac5 Mon Sep 17 00:00:00 2001 From: noveens Date: Wed, 1 Mar 2017 19:10:09 +0530 Subject: [PATCH 3/7] comment added to explain one check --- apps/files/js/filelist.js | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index b2d26ba3c807..30ebe044b1bd 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -550,6 +550,7 @@ _onUrlChanged: function(e) { if (e && _.isString(e.dir)) { var currentDir = this.getCurrentDirectory(); + // if this._currentDirectory is NULL when fileList is first initialised if(this._currentDirectory && currentDir === e.dir) { return; } From f7ef0c9aba68718d9bc7424cfa74288bd79eb1ff Mon Sep 17 00:00:00 2001 From: noveens Date: Wed, 1 Mar 2017 19:12:01 +0530 Subject: [PATCH 4/7] comment added to explain one check --- apps/files/js/filelist.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 30ebe044b1bd..33cb1fd3c338 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -550,7 +550,7 @@ _onUrlChanged: function(e) { if (e && _.isString(e.dir)) { var currentDir = this.getCurrentDirectory(); - // if this._currentDirectory is NULL when fileList is first initialised + // this._currentDirectory is NULL when fileList is first initialised if(this._currentDirectory && currentDir === e.dir) { return; } From f636291984ef8d8f82548ee50408b6b1e742e0ce Mon Sep 17 00:00:00 2001 From: noveens Date: Wed, 1 Mar 2017 21:54:09 +0530 Subject: [PATCH 5/7] unit tests added --- apps/files/js/filelist.js | 2 +- apps/files/tests/js/filelistSpec.js | 38 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 33cb1fd3c338..1001f99600c1 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -551,7 +551,7 @@ if (e && _.isString(e.dir)) { var currentDir = this.getCurrentDirectory(); // this._currentDirectory is NULL when fileList is first initialised - if(this._currentDirectory && currentDir === e.dir) { + if( (this._currentDirectory || this.$el.find('#dir').val()) && currentDir === e.dir) { return; } this.changeDirectory(e.dir, false, true); diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 35aa28be83aa..c3abeb159c32 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -2991,4 +2991,42 @@ describe('OCA.Files.FileList tests', function() { testMountType(123, 'external-root', 'external', 'external'); }); }); + describe('file list should not refresh if url does not change', function() { + var fileListStub; + + beforeEach(function() { + fileListStub = sinon.stub(OCA.Files.FileList.prototype, 'changeDirectory'); + }); + afterEach(function() { + fileListStub.restore(); + }) + it('File list must not be refreshed', function() { + $('#app-content-files').trigger(new $.Event('urlChanged', {dir: '/subdir'})); + expect(fileListStub.notCalled).toEqual(true); + }); + }); + describe('after file list creation file list should refresh', function() { + var fileListStub; + + beforeEach(function() { + if (fileList) { + fileList.destroy(); + } + fileList = new OCA.Files.FileList($('#app-content-files'), { + filesClient: filesClient, + config: filesConfig, + enableUpload: true + }); + + fileListStub = sinon.stub(OCA.Files.FileList.prototype, 'changeDirectory'); + }); + afterEach(function() { + fileListStub.restore(); + }) + it('File list must be refreshed', function() { + console.log(fileList.getCurrentDirectory()); + $('#app-content-files').trigger(new $.Event('urlChanged', {dir: '/'})); + expect(fileListStub.notCalled).toEqual(false); + }); + }); }); From d7ccd9471e27d3ee6e8aae97ea9cee59c7fcd203 Mon Sep 17 00:00:00 2001 From: noveens Date: Thu, 2 Mar 2017 00:32:07 +0530 Subject: [PATCH 6/7] small fixes in unit tests --- apps/files/tests/js/filelistSpec.js | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index c3abeb159c32..ad9c69d6a9be 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -3004,27 +3004,7 @@ describe('OCA.Files.FileList tests', function() { $('#app-content-files').trigger(new $.Event('urlChanged', {dir: '/subdir'})); expect(fileListStub.notCalled).toEqual(true); }); - }); - describe('after file list creation file list should refresh', function() { - var fileListStub; - - beforeEach(function() { - if (fileList) { - fileList.destroy(); - } - fileList = new OCA.Files.FileList($('#app-content-files'), { - filesClient: filesClient, - config: filesConfig, - enableUpload: true - }); - - fileListStub = sinon.stub(OCA.Files.FileList.prototype, 'changeDirectory'); - }); - afterEach(function() { - fileListStub.restore(); - }) it('File list must be refreshed', function() { - console.log(fileList.getCurrentDirectory()); $('#app-content-files').trigger(new $.Event('urlChanged', {dir: '/'})); expect(fileListStub.notCalled).toEqual(false); }); From 064d4fa5fa4cc4b7cbf16d84e4757b0bbfb7eefa Mon Sep 17 00:00:00 2001 From: noveens Date: Thu, 2 Mar 2017 14:12:24 +0530 Subject: [PATCH 7/7] missing semicolon added --- apps/files/tests/js/filelistSpec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index ad9c69d6a9be..85121c3dcd34 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -2999,7 +2999,7 @@ describe('OCA.Files.FileList tests', function() { }); afterEach(function() { fileListStub.restore(); - }) + }); it('File list must not be refreshed', function() { $('#app-content-files').trigger(new $.Event('urlChanged', {dir: '/subdir'})); expect(fileListStub.notCalled).toEqual(true);