Skip to content

Commit

Permalink
Merge pull request #5893 from owncloud/fix-personal-redirects
Browse files Browse the repository at this point in the history
fix(resource loading): don't load root resources twice if homeFolder is set
  • Loading branch information
fschade authored Oct 13, 2021
2 parents 1fb0082 + c4c9ea2 commit e3cd448
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -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
67 changes: 27 additions & 40 deletions packages/web-app-files/src/views/Personal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}),
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e3cd448

Please sign in to comment.