From 8c63c1cfbb2d97ca8fab954f7b62911eb211a928 Mon Sep 17 00:00:00 2001 From: Hornwitser Date: Fri, 13 Jun 2025 20:51:24 +0200 Subject: [PATCH] Fix sanity checks failing on deleted entities If the event/shift that a location/role was referencing had been marked for deletion the sanity check would incorrectly refuse to delete the event/role. Fix by ignoring deleted events/shifts. --- utils/client-schedule.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/client-schedule.ts b/utils/client-schedule.ts index bd02514..1a14345 100644 --- a/utils/client-schedule.ts +++ b/utils/client-schedule.ts @@ -484,6 +484,8 @@ export class ClientSchedule extends ClientEntity { private checkLocationRefsForDeletion(id: Id) { for (const event of this.events.values()) { + if (event.deleted) + continue; for (const slot of event.slots) { for (let i = 0; i < slot.locations.length; i++) { if (slot.locations[i].id === id) { @@ -583,6 +585,9 @@ export class ClientSchedule extends ClientEntity { private checkRoleRefsForDeletion(id: Id) { for (const shift of this.shifts.values()) { + if (shift.deleted) { + continue; + } if (shift.role.id === id) { throw new Error(`Cannot delete role, shift "${shift.name}" depends on it`); }