Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve resource loading within spaces #6601

Merged
merged 2 commits into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Enhancement: Improve resource loading within spaces

We've improved the loading of resources within a space. This enhances performance and overall stability within spaces.

* The loading task will determine if a space needs to be fetched or not. Route changes within a space do not require the space the be fetched again. This also ensures that the space image and readme won't be fetched when navigating into subfolders.
* The space now gets set at the end of the loading task. This ensures that the space task has finished as soon as the image and readme get loaded.

https://github.com/owncloud/web/pull/6601
34 changes: 22 additions & 12 deletions packages/web-app-files/src/services/folder/loaderProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@ export class FolderLoaderProject implements FolderLoader {
const router = context.router
const store = context.store

const graphClient = clientService.graphAuthenticated(
store.getters.configuration.server,
store.getters.getToken
)

return useTask(function* (signal1, signal2, ref, sameRoute, path = null) {
ref.CLEAR_CURRENT_FILES_LIST()
const storageId = router.currentRoute.params.storageId
const graphResponse = yield graphClient.drives.getDrive(storageId)

if (!graphResponse.data) {
return
}
let space
if (!sameRoute) {
const graphClient = clientService.graphAuthenticated(
kulmann marked this conversation as resolved.
Show resolved Hide resolved
store.getters.configuration.server,
store.getters.getToken
)

const storageId = router.currentRoute.params.storageId
const graphResponse = yield graphClient.drives.getDrive(storageId)

if (!graphResponse.data) {
return
}

ref.space = buildSpace(graphResponse.data)
space = buildSpace(graphResponse.data)
} else {
space = ref.space
}

const webDavResponse = yield ref.$client.files.list(
buildWebDavSpacesPath(ref.$route.params.storageId, path || '')
Expand All @@ -37,7 +43,7 @@ export class FolderLoaderProject implements FolderLoader {
let resources = []
if (!path) {
// space front page -> use space as current folder
resources.push(ref.space)
resources.push(space)

const webDavResources = webDavResponse.map(buildResource)
webDavResources.shift() // Remove webdav entry for the space itself
Expand All @@ -56,6 +62,10 @@ export class FolderLoaderProject implements FolderLoader {
client: ref.$client,
currentFolder: currentFolder?.path
})

if (!sameRoute) {
ref.space = space
}
})
}
}
6 changes: 3 additions & 3 deletions packages/web-app-files/src/views/spaces/Project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,12 @@ export default {
},
watch: {
$route: {
handler: function (to, from) {
const sameRoute = to.name === from?.name
handler: async function (to, from) {
const sameRoute = to.name === from?.name && to.params?.storageId === from?.params?.storageId
JammingBen marked this conversation as resolved.
Show resolved Hide resolved
const sameItem = to.params?.item === from?.params?.item

if ((!sameRoute || !sameItem) && from) {
this.loadResourcesTask.perform(this, sameRoute, to.params.item)
await this.loadResourcesTask.perform(this, sameRoute, to.params.item)
}

if (this.$refs.markdownContainer) {
Expand Down