Surface machine settings in the exercise library and refine machine rigs
Library detail screens now lead with the user's recorded machine settings (per-split when they disagree, empty-state card for machine-based entries) and append the weight progression chart. Starter seeds mark machine exercises with an empty machineSettings list so the settings UI lights up before first use. The figure rig gains a frontal body profile for face-on machines, props that can ride mid joints (knees/elbows), and an alternating four-frame Bird Dog loop. Claude-Session: https://claude.ai/code/session_01LEoff8bXGBS83tK1c55Mf7
This commit is contained in:
@@ -311,6 +311,24 @@ final class SyncEngine {
|
||||
do { try context.save() } catch { report("Cache save failed", error) }
|
||||
}
|
||||
|
||||
/// Push edited machine settings onto the originating split's exercise (matched
|
||||
/// by name — logs reference exercises by name only), following the seed
|
||||
/// clone-on-edit redirect so the live clone is updated. Skips silently when the
|
||||
/// split is gone or no exercise matches, and when nothing changed (so a pristine
|
||||
/// seed isn't needlessly forked). Never caches the split's id across the save,
|
||||
/// since saving a seed mints a new one.
|
||||
func writeBackMachineSettings(_ settings: [MachineSetting], exerciseName: String, splitID: String?) async {
|
||||
guard let splitID else { return }
|
||||
let liveID = currentSplitID(for: splitID)
|
||||
guard let split = CacheMapper.fetchSplit(id: liveID, in: context) else { return }
|
||||
var splitDoc = SplitDocument(from: split)
|
||||
guard let idx = splitDoc.exercises.firstIndex(where: { $0.name == exerciseName }) else { return }
|
||||
guard splitDoc.exercises[idx].machineSettings != settings else { return }
|
||||
splitDoc.exercises[idx].machineSettings = settings
|
||||
splitDoc.updatedAt = Date()
|
||||
await save(split: splitDoc)
|
||||
}
|
||||
|
||||
func save(workout doc: WorkoutDocument) async {
|
||||
guard let store else { return }
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user