fix(settings): update group counts after editUserMultiField

-e
Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
This commit is contained in:
Peter Ringelmann 2026-04-23 10:46:15 +02:00
parent 88734792b7
commit cf2d31597f

View file

@ -225,9 +225,22 @@ const mutations = {
*/
editUserMultiField(state, { userid, data }) {
const index = state.users.findIndex((user) => user.id === userid)
if (index !== -1) {
state.users.splice(index, 1, { ...state.users[index], ...data })
if (index === -1) {
return
}
// Delegate group membership changes so sidebar usercount stays in sync.
if (Array.isArray(data.groups)) {
const prevGids = state.users[index].groups ?? []
for (const gid of data.groups.filter((g) => !prevGids.includes(g))) {
this.commit('addUserGroup', { userid, gid })
}
for (const gid of prevGids.filter((g) => !data.groups.includes(g))) {
this.commit('removeUserGroup', { userid, gid })
}
}
state.users.splice(index, 1, { ...state.users[index], ...data })
},
/**