Skip to content

Commit

Permalink
Merge pull request #10588 from nextcloud/fix/noid/reduce-sharedItems-…
Browse files Browse the repository at this point in the history
…fetch

fix(RightSidebar) - Optimize update active tab ( sharedItems)
  • Loading branch information
Antreesy authored Sep 25, 2023
2 parents ded7b01 + e932eee commit c5d6340
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 c5d6340

Please sign in to comment.