diff --git a/changelog/unreleased/bugfix-space-member-count b/changelog/unreleased/bugfix-space-member-count new file mode 100644 index 00000000000..d3b3c3af090 --- /dev/null +++ b/changelog/unreleased/bugfix-space-member-count @@ -0,0 +1,5 @@ +Bugfix: Prevent the member count inside a space from disappearing + +We've fixed a bug where opening the sidebar for a file inside a space caused the member count of the space to disappear. + +https://github.com/owncloud/web/pull/6550 diff --git a/packages/web-app-files/src/helpers/resources.js b/packages/web-app-files/src/helpers/resources.js index 92529208c9b..b5c5e02b0fa 100644 --- a/packages/web-app-files/src/helpers/resources.js +++ b/packages/web-app-files/src/helpers/resources.js @@ -166,6 +166,7 @@ export function buildSpace(space) { disabled, spaceQuota: space.quota, spaceRoles, + spaceMemberIds: Object.values(spaceRoles).reduce((arr, ids) => arr.concat(ids), []), spaceImageData, spaceReadmeData, canUpload: function () { diff --git a/packages/web-app-files/src/views/spaces/Project.vue b/packages/web-app-files/src/views/spaces/Project.vue index c1fa85ce918..aad589e700f 100644 --- a/packages/web-app-files/src/views/spaces/Project.vue +++ b/packages/web-app-files/src/views/spaces/Project.vue @@ -71,7 +71,7 @@ @@ -271,18 +271,9 @@ export default { }) }) - const loadSharesTask = useTask(function* (signal, ref) { - yield ref.loadCurrentFileOutgoingShares({ - client: graphClient, - path: ref.space.id, - space: ref.space - }) - }) - return { space, loadResourcesTask, - loadSharesTask, resourceTargetLocation: createLocationSpaces('files-spaces-project'), paginatedResources, paginationPages, @@ -309,8 +300,7 @@ export default { 'selectedFiles', 'currentFolder', 'totalFilesCount', - 'totalFilesSize', - 'currentFileOutgoingCollaborators' + 'totalFilesSize' ]), selected: { @@ -339,15 +329,14 @@ export default { displayThumbnails() { return !this.configuration.options.disablePreviews }, - peopleCountString() { - const translated = this.$ngettext( - '%{count} member', - '%{count} members', - this.currentFileOutgoingCollaborators.length - ) + memberCount() { + return this.space.spaceMemberIds.length + }, + memberCountString() { + const translated = this.$ngettext('%{count} member', '%{count} members', this.memberCount) return this.$gettextInterpolate(translated, { - count: this.currentFileOutgoingCollaborators.length + count: this.memberCount }) }, quotaModalIsOpen() { @@ -419,7 +408,6 @@ export default { }, async mounted() { await this.loadResourcesTask.perform(this, false, this.$route.params.item || '') - this.loadSharesTask.perform(this) if (this.markdownResizeObserver) { this.markdownResizeObserver.unobserve(this.$refs.markdownContainer) diff --git a/packages/web-app-files/tests/unit/views/spaces/Project.spec.js b/packages/web-app-files/tests/unit/views/spaces/Project.spec.js index c8bfa13aa4b..53194e2e0d4 100644 --- a/packages/web-app-files/tests/unit/views/spaces/Project.spec.js +++ b/packages/web-app-files/tests/unit/views/spaces/Project.spec.js @@ -39,6 +39,7 @@ const spaceMocks = { spaceWithReadmeAndImage: { id: 1, name: 'space', + root: { permissions: [{ roles: ['manager'], grantedTo: [{ user: { id: 1 } }] }] }, special: [ { specialFolder: { name: 'readme' }, @@ -55,6 +56,7 @@ const spaceMocks = { spaceWithoutReadmeAndImage: { id: 1, name: 'space', + root: { permissions: [{ roles: ['manager'], grantedTo: [{ user: { id: 1 } }] }] }, special: [] } }