Use find/splice instead of filter

This commit is contained in:
Andrew Kingston 2025-01-07 12:27:29 +00:00
parent a286685900
commit 47e0913c54
No known key found for this signature in database
1 changed files with 6 additions and 3 deletions

View File

@ -47,9 +47,12 @@ class GroupStore extends BudiStore<UserGroup[]> {
async delete(group: UserGroup) {
await API.deleteGroup(group._id!, group._rev!)
this.update(state => {
state = state.filter(state => state._id !== group._id)
return state
this.update(groups => {
const index = groups.findIndex(g => g._id === group._id)
if (index !== -1) {
groups.splice(index, 1)
}
return groups
})
}