Closed GideonNeedleman closed 10 months ago
Match up set from:
programData[].workouts.exercises[].sets[].id
with:
tempWorkoutData[].setId
Then update metrics values in
programData[].workouts.exercises[].sets[].metrics (.weight or .reps)
With metrics values in
tempWorkoutData[].metrics (.weight or .reps)
Only if metric key is adaptive as matched in
programData[].workouts.exercises[].metrics[].name
With boolean value stored in
programData[].workouts.exercises[].metrics[].adaptive
Ok, here's the algorithm. First go to each set in programData
programData[].workouts.exercises[].sets[]
and check if the id matches with setId of any set in tempWorkoutData
:
tempWorkoutData[]
If it matches then need to iterate over adaptive metrics by getting list of adaptive metrics in:
programData[].workouts.exercises[].metrics[]
So essentially go through this array and if .adaptive === true
then grab metric NAME from .name
and then overwrite programData[].workouts.exercises[].sets[].metrics.NAME
with the value in tempWorkoutData[].metrics.NAME
Or could I make a copy of the workout (maybe use activeWorkout
or a new tempAdaptingWorkout
state) and dynamically update the state as I finish sets. Then upon finishing the workout overwrite the workout in programData
with the temp workout.
Going to try updating activeWorkout
as sets are submitted. 2 possible issues:
activeWorkout
was used as a flag to display SelectWorkout
or DoWorkout
. I switched this to using activeProgramId
. Should be functionally equivalent.activeWorkout
as we go along will pass through to programData
. Is activeWorkout
a copy or a reference? If it's a reference then I'll need to make it a copy by doing activeWorkout: {...action.payload.workout}
when 'select-workout'
For adaptive metrics, overwrite default values in
programData
with the values from your workout upon finishing the workout.Basically need to copy set metric values from
tempWorkoutData
toprogramData
on finish workout.