]> source.dussan.org Git - nextcloud-server.git/commitdiff
filelist only refreshed if directory changes 3686/head
authornoveens <noveen.sachdeva@research.iiit.ac.in>
Wed, 1 Mar 2017 11:57:48 +0000 (17:27 +0530)
committerMorris Jobke <hey@morrisjobke.de>
Fri, 3 Mar 2017 03:43:44 +0000 (21:43 -0600)
check introduced at another method

comment added to explain one check

comment added to explain one check

unit tests added

small fixes in unit tests

missing semicolon added

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
apps/files/js/filelist.js
apps/files/tests/js/filelistSpec.js

index 3a59da53517df43f54eb2cf4c9b12813dfa347b9..1f4b8f0ec68a238160a960177a1bafd159ee59f0 100644 (file)
                 */
                _onUrlChanged: function(e) {
                        if (e && _.isString(e.dir)) {
+                               var currentDir = this.getCurrentDirectory();
+                               // this._currentDirectory is NULL when fileList is first initialised
+                               if( (this._currentDirectory || this.$el.find('#dir').val()) && currentDir === e.dir) {
+                                       return;
+                               }
                                this.changeDirectory(e.dir, false, true);
                        }
                },
index c5a75be7c627d5f193d7fd5d6f8aed37a8813f0b..f3c04c48cb325d12e188e9f1c7b5d188aa17a9aa 100644 (file)
@@ -3005,4 +3005,22 @@ 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);
+               });
+               it('File list must be refreshed', function() {
+                       $('#app-content-files').trigger(new $.Event('urlChanged', {dir: '/'}));
+                       expect(fileListStub.notCalled).toEqual(false);
+               });
+       });
 });