Skip to content

Commit

Permalink
Merge pull request #10590 from nextcloud/backport/10588/stable27
Browse files Browse the repository at this point in the history
[stable27] fix(RightSidebar) - Optimize update active tab ( sharedItems)
  • Loading branch information
DorraJaouad authored Sep 26, 2023
2 parents 09b90ad + 8da1bff commit 1ee7133
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 26 deletions.
11 changes: 2 additions & 9 deletions src/components/RightSidebar/RightSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,7 @@ export default {
this.conversationName = this.conversation.displayName
}

if (newConversation.token === oldConversation.token) {
return
}

if (this.isOneToOne) {
this.activeTab = 'shared-items'
if (newConversation.token === oldConversation.token || this.isOneToOne) {
return
}

Expand Down Expand Up @@ -321,9 +316,7 @@ export default {
}

// In other case switch to other tabs
if (this.isOneToOne) {
this.activeTab = 'shared-items'
} else {
if (!this.isOneToOne) {
this.activeTab = 'participants'
}
},
Expand Down
37 changes: 20 additions & 17 deletions src/components/RightSidebar/SharedItems/SharedItemsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
-->

<template>
<div v-if="!loading && active">
<LoadingComponent v-if="loading" class="tab-loading" />
<div v-else>
<!-- Shared items grouped by type -->
<template v-for="type in sharedItemsOrder">
<div v-if="sharedItems[type]" :key="type">
Expand Down Expand Up @@ -89,6 +90,7 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import NcRelatedResourcesPanel from '@nextcloud/vue/dist/Components/NcRelatedResourcesPanel.js'

import LoadingComponent from '../../LoadingComponent.vue'
import SharedItems from './SharedItems.vue'
import SharedItemsBrowser from './SharedItemsBrowser.vue'

Expand All @@ -107,6 +109,7 @@ export default {
CollectionList,
DotsHorizontal,
FolderMultipleImage,
LoadingComponent,
NcAppNavigationCaption,
NcButton,
NcEmptyContent,
Expand Down Expand Up @@ -164,25 +167,21 @@ export default {
hasSharedItems() {
return Object.keys(this.$store.getters.sharedItems(this.token)).length > 0
},
},

watch: {
active: {
immediate: true,
handler(newValue) {
if (newValue && this.token) {
this.getSharedItemsOverview()
}
},
isSidebarOpen() {
return this.$store.getters.getSidebarStatus
},

token: {
immediate: true,
handler(newValue) {
if (newValue && this.active) {
this.getSharedItemsOverview()
}
},
sharedItemsIdentifier() {
return this.token + ':' + this.active + ':' + this.isSidebarOpen
},
},

watch: {
sharedItemsIdentifier() {
if (this.token && this.active && this.isSidebarOpen) {
this.getSharedItemsOverview()
}
},
},

Expand Down Expand Up @@ -224,4 +223,8 @@ export default {
}
}
}

.tab-loading {
margin-top: 50%;
}
</style>

0 comments on commit 1ee7133

Please sign in to comment.