diff --git a/changelog/unreleased/bugfix-unnecessary-redirects-personal-home-folder b/changelog/unreleased/bugfix-unnecessary-redirects-personal-home-folder new file mode 100644 index 00000000000..727470e8f74 --- /dev/null +++ b/changelog/unreleased/bugfix-unnecessary-redirects-personal-home-folder @@ -0,0 +1,8 @@ +Bugfix: Unnecessary redirects on personal page + +Navigating to all files could lead to loading resources twice, first resources from root (/) and second the resources from the homeFolder (options.homeFolder). +We've fixed this by detecting those cases and only load resources for the homeFolder. + +https://github.com/owncloud/web/pull/5893 +https://github.com/owncloud/web/issues/5085 +https://github.com/owncloud/web/issues/5875 diff --git a/packages/web-app-files/src/views/Personal.vue b/packages/web-app-files/src/views/Personal.vue index cee82207fae..d043cbef8fa 100644 --- a/packages/web-app-files/src/views/Personal.vue +++ b/packages/web-app-files/src/views/Personal.vue @@ -108,22 +108,6 @@ export default { MixinFilesListFilter ], - beforeRouteEnter(to, from, next) { - next((vm) => { - if (vm.isRedirectToHomeFolderRequired(to)) { - vm.redirectToHomeFolder(to) - } - }) - }, - - async beforeRouteUpdate(to, from, next) { - if (this.isRedirectToHomeFolderRequired(to)) { - await this.redirectToHomeFolder(to) - return - } - next() - }, - data: () => ({ loading: true }), @@ -177,10 +161,35 @@ export default { watch: { $route: { handler: function (to, from) { - this.$_filesListPagination_updateCurrentPage() - const sameRoute = to.name === from?.name const sameItem = to.params?.item === from?.params?.item + + const needsRedirectToHome = + this.homeFolder !== '/' && + isNil(to.params.item) && + !to.path.endsWith('/') && + (!sameRoute || !sameItem) + if (needsRedirectToHome) { + this.$router.replace( + { + name: to.name, + params: { + ...to.params, + item: this.homeFolder + }, + query: to.query + }, + () => {}, + (e) => { + console.error(e) + } + ) + + return + } + + this.$_filesListPagination_updateCurrentPage() + if (!sameRoute || !sameItem) { this.loadResources(sameRoute) } @@ -223,28 +232,6 @@ export default { ]), ...mapMutations(['SET_QUOTA']), - isRedirectToHomeFolderRequired(to) { - return isNil(to.params.item) - }, - - async redirectToHomeFolder(to) { - const route = { - name: to.name, - params: { - ...to.params, - item: to.path.endsWith('/') ? '/' : this.homeFolder - }, - query: to.query - } - await this.$router.replace( - route, - () => {}, - (e) => { - console.error(e) - } - ) - }, - async fileDropped(fileIdTarget) { const selected = [...this.selectedFiles] const targetInfo = this.activeFilesCurrentPage.find((e) => e.id === fileIdTarget)