Skip to content

Commit

Permalink
refactor(vue): Use return early principle to count users
Browse files Browse the repository at this point in the history
This refactor makes the code easier to read by reducing nesting and improving clarity.
  • Loading branch information
zak39 committed Jan 13, 2025
1 parent c373fe4 commit 6577c54
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/AddUsersTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,22 +172,25 @@ export default {
this.$emit('close-sidebar')
const space = this.$store.state.spaces[this.$route.params.space]
this.allSelectedUsers.forEach(user => {
if (this.$route.params.slug !== undefined) {
if (decodeURIComponent(this.$route.params.slug).startsWith('SPACE-U')) {
this.addUserFromUserGroup(user)
return
}
if (decodeURIComponent(this.$route.params.slug).startsWith('SPACE-GE')) {
this.addUserFromManagerGroup(user, space)
return
}
if (Object.keys(space.users).includes(user.uid) && decodeURIComponent(this.$route.params.slug).startsWith('SPACE-G-')) {
this.addExistingUserFromSubgroup(user)
} else {
this.addNewUserFromSubgroup(user, space)
}
} else {
if (this.$route.params.slug === undefined) {
this.addUserFromWorkspace(user, space)
return
}

if (decodeURIComponent(this.$route.params.slug).startsWith('SPACE-U')) {
this.addUserFromUserGroup(user)
return
}

if (decodeURIComponent(this.$route.params.slug).startsWith('SPACE-GE')) {
this.addUserFromManagerGroup(user, space)
return
}

if (Object.keys(space.users).includes(user.uid) && decodeURIComponent(this.$route.params.slug).startsWith('SPACE-G-')) {
this.addExistingUserFromSubgroup(user)
} else {
this.addNewUserFromSubgroup(user, space)
}
})
},
Expand Down

0 comments on commit 6577c54

Please sign in to comment.