From 4f5b072c74dd508bac685b170a74e3d43b865134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 19 Oct 2018 20:32:15 +0200 Subject: [PATCH] Fix opening a section again in the Files app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- apps/files/js/favoritesplugin.js | 7 ++++++- apps/files/js/filelist.js | 4 ++++ apps/files/js/recentplugin.js | 7 ++++++- apps/files_sharing/js/app.js | 18 +++++++++++++++--- apps/files_trashbin/js/app.js | 6 +++++- apps/systemtags/js/app.js | 7 ++++++- 6 files changed, 42 insertions(+), 7 deletions(-) diff --git a/apps/files/js/favoritesplugin.js b/apps/files/js/favoritesplugin.js index 454a505c7b..58a6101399 100644 --- a/apps/files/js/favoritesplugin.js +++ b/apps/files/js/favoritesplugin.js @@ -67,7 +67,12 @@ return new OCA.Files.FavoritesFileList( $el, { fileActions: fileActions, - scrollContainer: $('#app-content') + scrollContainer: $('#app-content'), + // 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 } ); }, diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 8b311e57d1..0686968b98 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -221,6 +221,10 @@ return; } + if (options.shown) { + this.shown = options.shown; + } + if (options.config) { this._filesConfig = options.config; } else if (!_.isUndefined(OCA.Files) && !_.isUndefined(OCA.Files.App)) { diff --git a/apps/files/js/recentplugin.js b/apps/files/js/recentplugin.js index fcd427b18a..5551aec9d3 100644 --- a/apps/files/js/recentplugin.js +++ b/apps/files/js/recentplugin.js @@ -67,7 +67,12 @@ return new OCA.Files.RecentFileList( $el, { fileActions: fileActions, - scrollContainer: $('#app-content') + scrollContainer: $('#app-content'), + // 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 } ); }, diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js index e6c9159eda..15c5bcb307 100644 --- a/apps/files_sharing/js/app.js +++ b/apps/files_sharing/js/app.js @@ -34,7 +34,11 @@ OCA.Sharing.App = { scrollContainer: $('#app-content'), 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 } ); @@ -57,7 +61,11 @@ OCA.Sharing.App = { scrollContainer: $('#app-content'), 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 } ); @@ -80,7 +88,11 @@ OCA.Sharing.App = { scrollContainer: $('#app-content'), 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 } ); diff --git a/apps/files_trashbin/js/app.js b/apps/files_trashbin/js/app.js index fd3d5db32f..c37de63097 100644 --- a/apps/files_trashbin/js/app.js +++ b/apps/files_trashbin/js/app.js @@ -30,7 +30,11 @@ OCA.Trashbin.App = { fileActions: this._createFileActions(), detailsViewEnabled: false, scrollTo: urlParams.scrollto, - 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 } ); }, diff --git a/apps/systemtags/js/app.js b/apps/systemtags/js/app.js index e027c0be12..ff0ac159ba 100644 --- a/apps/systemtags/js/app.js +++ b/apps/systemtags/js/app.js @@ -29,7 +29,12 @@ id: 'systemtags', scrollContainer: $('#app-content'), 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 } );