Skip to content

Commit 06d4d45

Browse files
cubapthehabes
andauthored
407 do over (#458)
* caller choses whether to save after * Add shouldUpdate flag to Group role methods Introduce an optional shouldUpdate parameter to Group.setMemberRoles and Group.removeMemberRoles to control whether changes are immediately persisted. These methods now skip calling update() when shouldUpdate is false, allowing callers to batch multiple role mutations and perform a single update. Call sites updated: removed a redundant update in Project.removeMember flow and adjusted memberRouter to pass shouldUpdate=false for intermediate role changes, then call group.update() once after all changes. This reduces redundant DB writes and improves efficiency. * auditfix * whitespace * No updated packages yet --------- Co-authored-by: Bryan Haberberger <bryan.j.haberberger@slu.edu>
1 parent 381eb37 commit 06d4d45

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

classes/Group/Group.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ export default class Group {
191191
const member = this.data.members[memberId]
192192
if (!member) {
193193
throw {
194-
status: 400,
195-
message: "User is not a member of this group"
194+
status: 400,
195+
message: "User is not a member of this group"
196196
}
197197
}
198198
const userRoles = member.roles
@@ -324,8 +324,8 @@ export default class Group {
324324
await this.addMemberRoles(this.data.creator, "OWNER", true, false)
325325
}
326326
if (!this.getByRole("LEADER")?.length) {
327-
await this.addMemberRoles(this.data.creator, "LEADER", false, false)
328-
}
327+
await this.addMemberRoles(this.data.creator, "LEADER", false, false)
328+
}
329329
}
330330

331331
static async createNewGroup(creator, payload) {

0 commit comments

Comments
 (0)