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

[full-ci] Improve performance when loading folders and share indicators #8349

Merged
merged 16 commits into from
Feb 7, 2023
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,6 @@
Bugfix: Loading shares in deep nested folders

Loading shares and share indicators on page reloads in deep nested folders was not possible and has been fixed.

https://github.com/owncloud/web/issues/7655
https://github.com/owncloud/web/pull/8349
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Enhancement: Improve performance when loading folders and share indicators
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️


The performance when loading folders and share indicators has been improved by optimizing the way how shares are being loaded.

https://github.com/owncloud/web/issues/7721
https://github.com/owncloud/web/pull/8349
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
variation="inverse"
:data-testid="indicator.id"
:data-test-indicator-type="indicator.type"
@click="indicator.handler(resource, indicator.target)"
@click="indicator.handler(resource, indicator.target, $router)"
>
<oc-icon :name="indicator.icon" size="small" fill-type="line" />
</oc-button>
Expand Down
56 changes: 27 additions & 29 deletions packages/web-app-files/src/components/AppBar/CreateAndUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ import { urlJoin } from 'web-client/src/utils'
import { stringify } from 'qs'
import { useService } from 'web-pkg/src/composables/service'
import { UppyService } from 'web-runtime/src/services/uppyService'
import { getIndicators } from 'web-app-files/src/helpers/statusIndicators'

export default defineComponent({
components: {
Expand Down Expand Up @@ -252,7 +253,13 @@ export default defineComponent({
}),
computed: {
...mapGetters(['capabilities', 'configuration', 'newFileHandlers', 'user']),
...mapGetters('Files', ['files', 'currentFolder', 'selectedFiles', 'clipboardResources']),
...mapGetters('Files', [
'ancestorMetaData',
'files',
'currentFolder',
'selectedFiles',
'clipboardResources'
]),
...mapState('Files', ['areFileExtensionsShown']),
...mapGetters('runtime/spaces', ['spaces']),

Expand Down Expand Up @@ -317,15 +324,14 @@ export default defineComponent({
return false
}
return this.currentFolder.canUpload({ user: this.user })
},

loadIndicatorsForNewFile() {
return this.isSpacesGenericLocation && this.space.driveType !== 'share'
}
},
methods: {
...mapActions('Files', [
'loadPreview',
'loadIndicators',
'clearClipboardFiles',
'pasteSelectedFiles'
]),
...mapActions('Files', ['clearClipboardFiles', 'pasteSelectedFiles']),
...mapActions(['showMessage', 'createModal', 'setModalInputErrorMessage', 'hideModal']),
...mapMutations('Files', ['UPSERT_RESOURCE']),
...mapMutations('runtime/spaces', ['UPDATE_SPACE_FIELD']),
Expand Down Expand Up @@ -453,16 +459,14 @@ export default defineComponent({
const resource = await (this.$clientService.webdav as WebDAV).createFolder(this.space, {
path
})
this.UPSERT_RESOURCE(resource)
this.hideModal()

if (this.isSpacesGenericLocation && this.space.driveType !== 'share') {
this.loadIndicators({
client: this.$client,
currentFolder: this.currentFolder.path
})
if (this.loadIndicatorsForNewFile) {
resource.indicators = getIndicators({ resource, ancestorMetaData: this.ancestorMetaData })
}

this.UPSERT_RESOURCE(resource)
this.hideModal()

this.showMessage({
title: this.$gettextInterpolate(
this.$gettext('"%{folderName}" was created successfully'),
Expand Down Expand Up @@ -522,6 +526,10 @@ export default defineComponent({
path
})

if (this.loadIndicatorsForNewFile) {
resource.indicators = getIndicators({ resource, ancestorMetaData: this.ancestorMetaData })
}

this.UPSERT_RESOURCE(resource)

if (this.newFileAction) {
Expand All @@ -538,14 +546,6 @@ export default defineComponent({
}

this.hideModal()

if (this.isSpacesGenericLocation && this.space.driveType !== 'share') {
this.loadIndicators({
client: this.$client,
currentFolder: this.currentFolder.path
})
}

this.showMessage({
title: this.$gettextInterpolate(this.$gettext('"%{fileName}" was created successfully'), {
fileName
Expand Down Expand Up @@ -584,16 +584,14 @@ export default defineComponent({
const resource = await (this.$clientService.webdav as WebDAV).getFileInfo(this.space, {
path
})

if (this.loadIndicatorsForNewFile) {
resource.indicators = getIndicators({ resource, ancestorMetaData: this.ancestorMetaData })
}

this.$_fileActions_triggerDefaultAction({ space: this.space, resources: [resource] })
this.UPSERT_RESOURCE(resource)
this.hideModal()

if (this.isSpacesGenericLocation && this.space.driveType !== 'share') {
this.loadIndicators({
client: this.$client,
currentFolder: this.currentFolder.path
})
}
this.showMessage({
title: this.$gettextInterpolate(this.$gettext('"%{fileName}" was created successfully'), {
fileName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ import { computed, defineComponent, unref } from 'vue'
import { debounce } from 'lodash-es'
import { ImageDimension, ImageType } from 'web-pkg/src/constants'
import { VisibilityObserver } from 'web-pkg/src/observer'
import { mapActions, mapGetters, mapMutations } from 'vuex'
import { mapActions, mapGetters } from 'vuex'
import FileActions from '../../mixins/fileActions'
import MixinAcceptShare from '../../mixins/actions/acceptShare'
import MixinDeclineShare from '../../mixins/actions/declineShare'
Expand Down Expand Up @@ -258,8 +258,7 @@ export default defineComponent({
visibilityObserver.disconnect()
},
methods: {
...mapActions('Files', ['loadIndicators', 'loadPreview', 'loadAvatars']),
...mapMutations('Files', ['LOAD_FILES', 'CLEAR_CURRENT_FILES_LIST']),
...mapActions('Files', ['loadPreview', 'loadAvatars']),

rowMounted(resource, component) {
const debounced = debounce(({ unobserve }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export default defineComponent({
},
computed: {
...mapGetters('runtime/spaces', ['spaces']),
...mapGetters('Files', ['versions', 'sharesTree', 'sharesTreeLoading']),
...mapGetters('Files', ['ancestorMetaData', 'versions', 'sharesTree', 'sharesTreeLoading']),
...mapGetters(['user', 'configuration']),

matchingSpace() {
Expand Down Expand Up @@ -453,7 +453,7 @@ export default defineComponent({
)
},
shareIndicators() {
return getIndicators(this.resource, this.sharesTree)
return getIndicators({ resource: this.resource, ancestorMetaData: this.ancestorMetaData })
},
shares() {
if (this.sharedParentDir === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,7 @@ export default defineComponent({
this.currentFileOutgoingLinks.length === 1 ? this.currentFileOutgoingLinks[0].id : undefined

try {
await this.removeLink({
client,
share,
path,
storageId: resource.fileId,
loadIndicators: !!lastLinkId
})
await this.removeLink({ client, share, path, loadIndicators: !!lastLinkId })
this.showMessage({
title: this.$gettext('Link was deleted successfully')
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ export default defineComponent({
client: this.$client,
share: share,
path,
storageId: this.resource.fileId,
loadIndicators: !!lastShareId
})

Expand Down
20 changes: 11 additions & 9 deletions packages/web-app-files/src/components/SideBar/SideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ export default defineComponent({
const highlightedFileIsSpace = computed(() => {
return isProjectSpaceResource(unref(highlightedFile) || {})
})
const highlightedSpace = computed(() => {
return store.getters['runtime/spaces/spaces'].find((s) => s.id === unref(highlightedFile).id)
})
const sharesLoadingDisabledOnCurrentRoute = computed(() => {
return unref(isPublicFilesLocation) || unref(isTrashLocation)
})
Expand Down Expand Up @@ -204,9 +207,7 @@ export default defineComponent({

const getSelectedResource = () => {
if (unref(highlightedFileIsSpace) && unref(selectedFiles).length) {
return store.getters['runtime/spaces/spaces'].find(
(s) => s.id === unref(highlightedFile).id
)
return unref(highlightedSpace)
}
if (unref(selectedFiles).length === 1) {
return unref(selectedFiles)[0]
Expand Down Expand Up @@ -254,8 +255,11 @@ export default defineComponent({
}

watch(
selectedFiles,
(newResource, oldResource) => {
() => [...unref(selectedFiles), props.open],
() => {
if (!props.open) {
return
}
if (
unref(selectedFiles).length === 1 &&
unref(loadedResource)?.id === unref(selectedFiles)[0].id
Expand All @@ -267,16 +271,14 @@ export default defineComponent({
loading.value = true
let selectedResource = getSelectedResource()
if (selectedResource) {
const shouldLoadShares =
!unref(sharesLoadingDisabledOnCurrentRoute) && (!!oldResource || !unref(currentFolder))
if (shouldLoadShares) {
if (!unref(sharesLoadingDisabledOnCurrentRoute)) {
loadShares()
}

if (unref(highlightedFileIsSpace)) {
store.dispatch('runtime/spaces/loadSpaceMembers', {
graphClient: unref(graphClient),
space: selectedResource
space: unref(highlightedSpace)
})
}

Expand Down
Loading