fix(settings): Only change usercount if group can be found

Signed-off-by: Christopher Ng <chrng8@gmail.com>
pull/51336/head
Christopher Ng 2025-03-25 14:31:44 +07:00
parent 31ffa337bd
commit 6edbeb7052
1 changed files with 11 additions and 3 deletions

@ -159,6 +159,9 @@ const mutations = {
state.userCount += user.enabled ? 1 : -1 // update Active Users count
user.groups.forEach(userGroup => {
const group = state.groups.find(groupSearch => groupSearch.id === userGroup)
if (!group) {
return
}
group.disabled += user.enabled ? -1 : 1 // update group disabled count
})
break
@ -167,9 +170,11 @@ const mutations = {
state.userCount++ // increment Active Users count
user.groups.forEach(userGroup => {
state.groups
.find(groupSearch => groupSearch.id === userGroup)
.usercount++ // increment group total count
const group = state.groups.find(groupSearch => groupSearch.id === userGroup)
if (!group) {
return
}
group.usercount++ // increment group total count
})
break
case 'remove':
@ -188,6 +193,9 @@ const mutations = {
disabledGroup.usercount-- // decrement Disabled Users count
user.groups.forEach(userGroup => {
const group = state.groups.find(groupSearch => groupSearch.id === userGroup)
if (!group) {
return
}
group.disabled-- // decrement group disabled count
})
}