feat: auto create empty schedule when deleted all schedules (#552)

* feat: enhance schedule deletion to create a new schedule if none remain

* feat: set active index to new schedule if only one exists

* chore: run lint

* feat: enhance schedule deletion to create a new schedule if none remain

* feat: set active index to new schedule if only one exists

* chore: run lint

* feat: reset schedules on update, refactor invariant to within deleteSchedule

* chore: pnpm lint

---------

Co-authored-by: Samuel Gunter <29130894+Samathingamajig@users.noreply.github.com>
Co-authored-by: Samuel Gunter <sgunter@utexas.edu>
This commit is contained in:
Ethan Lanting
2025-04-01 13:24:08 -05:00
committed by GitHub
parent 630d0d80d2
commit 7c2beef193
3 changed files with 21 additions and 0 deletions

View File

@@ -36,5 +36,11 @@ export default async function createSchedule(scheduleName: string) {
schedules.push(newSchedule);
await UserScheduleStore.set('schedules', schedules);
// If there is only one schedule, set the active index to the new schedule
if (schedules.length <= 1) {
await UserScheduleStore.set('activeIndex', 0);
}
return newSchedule.id;
}