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

fix(RightSidebar) - Optimize update active tab ( sharedItems) #10588

Merged
merged 2 commits into from
Sep 25, 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
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>