Skip to content

Commit

Permalink
Potential fix for wrong notification order on slot change
Browse files Browse the repository at this point in the history
  • Loading branch information
Alf-Melmac committed Aug 10, 2021
1 parent 08683f7 commit 701abf0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/de/webalf/slotbot/model/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ void removeSquad(Squad squad) {
getSquadList().remove(squad);
}

public void unslotIfAlreadySlotted(User user) {
findSlotOfUser(user).ifPresent(oldSlot -> oldSlot.unslotWithoutUpdate(user));
}

/**
* Informs the event about an slot update (slot, unslot, new slot(s) created, slot(s) removed).
* Uses {@link Event#moveReservists()} to change reserve if needed
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/webalf/slotbot/service/EventService.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ public Event slot(long channel, int slotNumber, UserDto userDto) {
Event event = findByChannel(channel);
Slot slot = event.findSlot(slotNumber).orElseThrow(ResourceNotFoundException::new);
User user = userService.find(userDto);
event.unslotIfAlreadySlotted(user);
eventRepository.saveAndFlush(event);
slotService.slot(slot, user);
return event;
}
Expand Down

0 comments on commit 701abf0

Please sign in to comment.