]> source.dussan.org Git - nextcloud-server.git/commitdiff
Do not reload the filelist on first open 4693/head
authorRoeland Jago Douma <roeland@famdouma.nl>
Thu, 4 May 2017 11:23:04 +0000 (13:23 +0200)
committerRoeland Jago Douma <roeland@famdouma.nl>
Thu, 4 May 2017 11:29:49 +0000 (13:29 +0200)
Fixes: #4644
Without this patch the filelist would always reload. However since not
all the correct data was set yet it would often:

1. fireoff a propfind to ../webdav/
2. fireoff a propfind to ../webdav/<PATH>

When just opening the file list those are the same so the result is just
fine. However if opening a direct link it means that there is a race
condition on which finishes first.

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
apps/files/js/filelist.js
apps/files/tests/js/filelistSpec.js

index db85caf65fa5f83c9d85586f48027d616e8a9980..187ede8c0bd715f49b983c596a203cd82b9c6337 100644 (file)
                 */
                initialized: false,
 
+               /**
+                * Wheater the file list was already shown once
+                * @type boolean
+                */
+               shown: false,
+
                /**
                 * Number of files per page
                 *
                 * Event handler when leaving previously hidden state
                 */
                _onShow: function(e) {
-                       this.reload();
+                       if (this.shown) {
+                               this.reload();
+                       }
+                       this.shown = true;
                },
 
                /**
index 934aa054fb6dfe05163875fef2754754ca5ebb6b..6b403e7fa856adc9b6b1e3732d3cfcef05fa5f81 100644 (file)
@@ -1509,6 +1509,12 @@ describe('OCA.Files.FileList tests', function() {
                });
                it('reloads the list when leaving hidden state', function() {
                        var reloadStub = sinon.stub(fileList, 'reload');
+
+                       // First show should not trigger
+                       $('#app-content-files').trigger(new $.Event('show'));
+                       expect(reloadStub.calledOnce).toEqual(false);
+
+                       // Second show should!
                        $('#app-content-files').trigger(new $.Event('show'));
                        expect(reloadStub.calledOnce).toEqual(true);
                        reloadStub.restore();