goalert
goalert copied to clipboard
rotation advancing on user remove
Describe the Bug: When removing a user from a rotation, the list of users and who is active gets shifted unexpectedly. As a user, I would expect the current on-call person to stay on call.
Steps to Reproduce:
- Go to a rotation with a few users
- Click on 'Remove user' on someone before the active user
- Confirm, and notice the active user shift
Expected Behavior:
- Active user does not shift when removing a rotation participant
I feel like we've had and fixed this bug before; fixing this should include a test for the regression
Failing inside of updateRotationParticipants
when calling updateRotation
with a list of userIDs to remove:
if len(userIDs) == 0 {
// Delete rotation state if all users are going to be deleted as per new input
err = m.RotationStore.DeleteStateTx(ctx, tx, rotationID)
if err != nil {
return err
}
} else if updateActive {
// get current active participant
s, err := m.RotationStore.StateTx(ctx, tx, rotationID)
if errors.Is(err, rotation.ErrNoState) {
return nil
}
if err != nil {
return err
}
// if currently active user is going to be deleted
// then set to first user before we actually delete any users
if s.Position >= len(userIDs) {
err = m.RotationStore.SetActiveIndexTx(ctx, tx, rotationID, 0)
if err != nil {
return err
}
}
}