]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix opening a section again in the Files app
authorDaniel Calviño Sánchez <danxuliu@gmail.com>
Fri, 19 Oct 2018 18:32:15 +0000 (20:32 +0200)
committerDaniel Calviño Sánchez <danxuliu@gmail.com>
Tue, 23 Oct 2018 14:44:26 +0000 (16:44 +0200)
When a section is open in the Files app a "show" event is triggered.
File list objects handle that event by reloading themselves, but only
if the file list was shown at least once. However, the file list objects
of plugins are created when the "show" event is triggered for the first
time for their section; as the file list objects register their handler
for the "show" event when they are created they never handle the first
triggered "show" event, as the handler is set while that event is being
already handled. Therefore, from the point of view of the handler, the
second time that a "show" event was triggered it was seen as if the file
list was shown for the first time, and thus it was not reloaded. Now the
"shown" property is explicitly set for those file lists that are created
while handling a "show" event, which causes them to be reloaded as
expected when opening their section again.

Note that it is not possible to just reload the file list whenever it is
shown; the file list is reloaded also when the directory changes, and
this can happen when the web page is initially loaded and the URL is
parsed. In that case, if file lists were reloaded when shown for the
first time then it could be reloaded twice, one with the default
parameters due to the "show" event and another one with the proper
parameters once the URL was parsed, and the files that appeard in the
list would depend on which response from the server was received the
last.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
apps/files/js/favoritesplugin.js
apps/files/js/filelist.js
apps/files/js/recentplugin.js
apps/files_sharing/js/app.js
apps/files_trashbin/js/app.js
apps/systemtags/js/app.js

index 7294ef9461cd88ceb316c2fed1ae98d4a8ff4b36..3ceadca826d954171f0b3f67d6f92de3c003db0a 100644 (file)
                        return new OCA.Files.FavoritesFileList(
                                $el, {
                                        fileActions: fileActions,
+                                       // The file list is created when a "show" event is handled,
+                                       // so it should be marked as "shown" like it would have been
+                                       // done if handling the event with the file list already
+                                       // created.
+                                       shown: true
                                }
                        );
                },
index 8fb8a021811272bc5a9f4e530b034e62e1199cf5..42b80189287f86539d30d180feefd356f5468a1f 100644 (file)
                                return;
                        }
 
+                       if (options.shown) {
+                               this.shown = options.shown;
+                       }
+
                        if (options.config) {
                                this._filesConfig = options.config;
                        } else if (!_.isUndefined(OCA.Files) && !_.isUndefined(OCA.Files.App)) {
index 524b556a517e895bc2585d21da748436fc96b393..c1b013ef1b85c62838f448f78eea826fc3c436d6 100644 (file)
                        return new OCA.Files.RecentFileList(
                                $el, {
                                        fileActions: fileActions,
+                                       // The file list is created when a "show" event is handled,
+                                       // so it should be marked as "shown" like it would have been
+                                       // done if handling the event with the file list already
+                                       // created.
+                                       shown: true
                                }
                        );
                },
index 750f66236ae3dfa5699797c61c8ae44d7fa4812c..b6ca71e15d11164ed8f52a050d67279d977d1377 100644 (file)
@@ -34,7 +34,11 @@ OCA.Sharing.App = {
                                id: 'shares.self',
                                sharedWithUser: true,
                                fileActions: this._createFileActions(),
-                               config: OCA.Files.App.getFilesConfig()
+                               config: OCA.Files.App.getFilesConfig(),
+                               // The file list is created when a "show" event is handled, so
+                               // it should be marked as "shown" like it would have been done
+                               // if handling the event with the file list already created.
+                               shown: true
                        }
                );
 
@@ -56,7 +60,11 @@ OCA.Sharing.App = {
                                id: 'shares.others',
                                sharedWithUser: false,
                                fileActions: this._createFileActions(),
-                               config: OCA.Files.App.getFilesConfig()
+                               config: OCA.Files.App.getFilesConfig(),
+                               // The file list is created when a "show" event is handled, so
+                               // it should be marked as "shown" like it would have been done
+                               // if handling the event with the file list already created.
+                               shown: true
                        }
                );
 
@@ -78,7 +86,11 @@ OCA.Sharing.App = {
                                id: 'shares.link',
                                linksOnly: true,
                                fileActions: this._createFileActions(),
-                               config: OCA.Files.App.getFilesConfig()
+                               config: OCA.Files.App.getFilesConfig(),
+                               // The file list is created when a "show" event is handled, so
+                               // it should be marked as "shown" like it would have been done
+                               // if handling the event with the file list already created.
+                               shown: true
                        }
                );
 
@@ -101,7 +113,11 @@ OCA.Sharing.App = {
                                showDeleted: true,
                                sharedWithUser: true,
                                fileActions: this._restoreShareAction(),
-                               config: OCA.Files.App.getFilesConfig()
+                               config: OCA.Files.App.getFilesConfig(),
+                               // The file list is created when a "show" event is handled, so
+                               // it should be marked as "shown" like it would have been done
+                               // if handling the event with the file list already created.
+                               shown: true
                        }
                );
 
@@ -122,7 +138,11 @@ OCA.Sharing.App = {
                        {
                                id: 'shares.overview',
                                config: OCA.Files.App.getFilesConfig(),
-                               isOverview: true
+                               isOverview: true,
+                               // The file list is created when a "show" event is handled, so
+                               // it should be marked as "shown" like it would have been done
+                               // if handling the event with the file list already created.
+                               shown: true
                        }
                );
 
index ae4a9b1841f7ae38ecd7380f8a9b1669dd5a2661..b345d876997e5640378067b38b6cc51b1002abf1 100644 (file)
@@ -41,7 +41,11 @@ OCA.Trashbin.App = {
                                                displayName: t('files', 'Delete'),
                                                iconClass: 'icon-delete',
                                        }
-                               ]
+                               ],
+                               // The file list is created when a "show" event is handled, so
+                               // it should be marked as "shown" like it would have been done
+                               // if handling the event with the file list already created.
+                               shown: true
                        }
                );
        },
index 04ac53d3b32475b6e867527054c437d2f246ea94..2ef88564528318774b897d469728b25ecca5d0e5 100644 (file)
                                {
                                        id: 'systemtags',
                                        fileActions: this._createFileActions(),
-                                       config: OCA.Files.App.getFilesConfig()
+                                       config: OCA.Files.App.getFilesConfig(),
+                                       // The file list is created when a "show" event is handled,
+                                       // so it should be marked as "shown" like it would have been
+                                       // done if handling the event with the file list already
+                                       // created.
+                                       shown: true
                                }
                        );