Resolve the seed redirect when editing a schedule's routine

A schedule made against a starter-seed routine keeps the retired seed id
after the routine is edited (clone-on-edit). The edit form matched that id
directly, so the routine read as unselected and Save stayed disabled; it
now resolves through sync.currentRoutineID like the Today board does, and
the routine picker's checkmark compares against the resolved id.
This commit is contained in:
2026-07-11 12:40:18 -04:00
parent 5ec5de9295
commit 1a1147b612
+14 -4
View File
@@ -117,8 +117,14 @@ struct ScheduleAddEditView: View {
private var isEditing: Bool { scheduleID != nil }
/// The live routine currently selected; nil when the stored id no longer resolves.
private var selectedRoutine: Routine? { routines.first { $0.id == routineID } }
/// The live routine currently selected, following the seed clone-on-edit redirect
/// (a schedule made against a starter seed keeps the retired seed id after the
/// routine is edited); nil when the routine has been deleted.
private var selectedRoutine: Routine? {
guard !routineID.isEmpty else { return nil }
let liveID = sync.currentRoutineID(for: routineID)
return routines.first { $0.id == liveID }
}
/// The When choices this presentation offers "Now" only when adding on today.
/// Built as a list (rather than conditionally hiding a tag inside the Picker)
@@ -171,7 +177,8 @@ struct ScheduleAddEditView: View {
private var routineSection: some View {
Section {
NavigationLink {
RoutinePickerList(routines: routines, selectedID: $routineID)
RoutinePickerList(routines: routines, currentID: selectedRoutine?.id,
selectedID: $routineID)
} label: {
HStack {
Text("Routine")
@@ -333,6 +340,9 @@ struct ScheduleAddEditView: View {
/// Tapping selects and pops back.
private struct RoutinePickerList: View {
let routines: [Routine]
/// The resolved live id of the current selection (for the checkmark) may differ
/// from the binding's stored value when a seed clone-on-edit redirect is in play.
let currentID: String?
@Binding var selectedID: String
@Environment(\.dismiss) private var dismiss
@@ -350,7 +360,7 @@ private struct RoutinePickerList: View {
Text(routine.name)
.foregroundStyle(.primary)
Spacer()
if routine.id == selectedID {
if routine.id == currentID {
Image(systemName: "checkmark")
.fontWeight(.semibold)
.foregroundStyle(Color.accentColor)