Skip to content

Commit f7beffd

Browse files
committed
feat: optimize member list
Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
1 parent 81a9b75 commit f7beffd

8 files changed

Lines changed: 259 additions & 82 deletions

File tree

src/components/AppContent/CircleContent.vue

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ export default {
5858
},
5959
},
6060
61-
data() {
62-
return {
63-
loadingList: false,
64-
}
65-
},
66-
6761
computed: {
6862
// store variables
6963
circles() {
@@ -82,25 +76,10 @@ export default {
8276
return Object.values(this.circle?.members || [])
8377
},
8478
85-
/**
86-
* Is the current circle empty
87-
*
88-
* @return {boolean}
89-
*/
90-
isEmptyCircle() {
91-
return this.members.length === 0
92-
},
93-
9479
...mapStores(useUserGroupStore),
9580
},
9681
9782
watch: {
98-
circle(newCircle) {
99-
if (newCircle?.id) {
100-
this.fetchCircleMembers(newCircle.id)
101-
}
102-
},
103-
10483
userGroup(newUserGroup) {
10584
if (newUserGroup?.id) {
10685
this.fetchUserGroupMembers(newUserGroup.id)
@@ -109,40 +88,18 @@ export default {
10988
},
11089
11190
beforeMount() {
112-
if (this.circle?.id) {
113-
this.fetchCircleMembers(this.circle.id)
114-
}
115-
11691
if (this.userGroup?.id) {
11792
this.fetchUserGroupMembers(this.userGroup.id)
11893
}
11994
},
12095
12196
methods: {
122-
async fetchCircleMembers(circleId) {
123-
this.loadingList = true
124-
this.logger.debug('Fetching members for', { circleId })
125-
126-
try {
127-
await this.$store.dispatch('getCircleMembers', circleId)
128-
} catch (error) {
129-
console.error(error)
130-
showError(t('contacts', 'There was an error fetching the member list'))
131-
} finally {
132-
this.loadingList = false
133-
}
134-
},
135-
13697
async fetchUserGroupMembers(userGroupId) {
137-
this.loadingList = true
138-
13998
try {
14099
await this.userGroupStore.getUserGroupMembers(userGroupId)
141100
} catch (error) {
142101
console.error(error)
143102
showError(t('contacts', 'There was an error fetching the member list'))
144-
} finally {
145-
this.loadingList = false
146103
}
147104
},
148105
},

src/components/MemberList/MemberGridItem.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181

8282
<script>
8383
import { DialogBuilder, showError } from '@nextcloud/dialogs'
84+
import { emit } from '@nextcloud/event-bus'
8485
import { NcActionButton, NcActions, NcActionSeparator, NcActionText, NcAvatar, NcButton } from '@nextcloud/vue'
8586
import IconAccountGroupOutline from 'vue-material-design-icons/AccountGroupOutline.vue'
8687
import IconCheckOutline from 'vue-material-design-icons/CheckOutline.vue'
@@ -317,6 +318,7 @@ export default {
317318
member: this.member,
318319
leave: this.isCurrentUser,
319320
})
321+
emit('contacts:circles:member:deleted')
320322
} catch (error) {
321323
if (error?.response?.status === 404) {
322324
this.logger.debug('Member is not in circle')
@@ -346,6 +348,7 @@ export default {
346348
// this.member is a class. We're modifying the class setter, not the prop itself
347349
// eslint-disable-next-line vue/no-mutating-props
348350
this.member.level = level
351+
emit('contacts:circles:member:changed')
349352
} catch (error) {
350353
this.logger.error('Could not change the member level', { level: CIRCLES_MEMBER_LEVELS[level], error })
351354
showError(t('contacts', 'Could not change the member level to {level}', {

0 commit comments

Comments
 (0)