Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting numberOfSets in Update Code Causes Extra Set To Be Added If/When Program Is Reloaded #219

Open
feraask opened this issue Nov 24, 2024 · 2 comments

Comments

@feraask
Copy link

feraask commented Nov 24, 2024

Basically, if you increment numberOfSets inside the update(setIndex == 0) call and you've already completed all sets for a given exercise it seems to be adding an extra set beyond what it should.

Here's how to reproduce using this test program:

  1. Start a workout or open the playground
  2. Complete all the initial existing sets
  3. Hit edit button on the exercise
  4. Change the targetRepsMin and/or targetRepsMax state variables to cause the workout to reload
  5. Notice an additional set was added even only though 1 set is defined in the program text and the setsModifier variable should only be incrementing numberOfSets by 1 in the update call to make a total of 2 sets, but you end up with 3.

If you complete the 3rd extra set and then do step 4 again you'll get another extra set added and so on...

Seems like it may be saving the modified numberOfSets value from the initial update call rather than re-reading the numberOfsets defined in the program file when reloading the program.

@astashov
Copy link
Owner

Hmm, I can see that people may expect it work both ways - that numberOfSets contain the current number of sets, and the initial ("required") number of sets.

Feels like instead I should introduce completedNumberOfSets - same pattern as the reps/completedReps, to distinguish between initially required number of sets, and completed number of sets.

@feraask
Copy link
Author

feraask commented Nov 26, 2024

Feels like instead I should introduce completedNumberOfSets - same pattern as the reps/completedReps, to distinguish between initially required number of sets, and completed number of sets.

Yea that could work too!

I can see that people may expect it work both ways - that numberOfSets contain the current number of sets, and the initial ("required") number of sets.

It's just weird right now where numberOfSets seems to only change value once all sets are completed for an exercise. Before that point it seems to be returning however many sets are prescribed in the program text regardless of however many you completed in the current session.

Then, only once you've completed all the sets for the day, it seems to make numberOfSets read as the total completed sets in the current session instead of the prescribed/required value, so if you then make a change which reloads the workout this issue happens.

So basically in the test program:

  1. Mark only set 1 as complete
  2. Change a state variable value
  3. Notice the workout reloads but still has the expected 2 sets (1 required/prescribed + 1 added via initial update) no extra 3rd set was added.
  4. Complete all sets
  5. Change a state variable value to reload the program again
  6. Notice it now adds an extra set and you end up with 3

Another annoyance is you may not see this issue until the end of the workout because it added sets to exercises you already completed earlier, and since the entire workout reloads if you change things for later exercises this issue still happens to the exercises you aren't even looking at anymore.

So unless you review your session before hitting finish or understand the "are you sure?" prompt that comes up when you hit finish is because there are now incomplete extra sets that were added to earlier exercises, it'll end up saving the workout with blank/incomplete sets which are confusing when you get to the workout summary screen.

Hopefully that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants