nkfoss / ohm-str

0 stars 0 forks source link

If workout is loaded from database, you can't delete the last remaining exercise #35

Closed nkfoss closed 3 years ago

nkfoss commented 4 years ago

If you load a previously saved workout, and there is only one exercise, you cannot delete it.

It will appear to be deleted, but will quickly appear again. This is probably related to some check of the length of the exercise array...

nkfoss commented 4 years ago

Update: When deleting the last exercise of a previously saved workout, it does not re-instate that last exercise, but it actually reinstsates THE ENTIRE WORKOUT that was saved last. This is a bit more informative of the problem.

nkfoss commented 4 years ago

New problem: It seems that fetchWorkout() is being called by multiple componnents, though I think it should only be called by the set-list component (for simplicity). This should be sorted out first.

michael-small commented 4 years ago

It is called twice because fetchWorkout() is called in SetListComponent's ngOnInit() twice. Once via calling handleRouteParams() which uses fetchWorkout(), and then fetchWorkout() in an if/else in init.

nkfoss commented 4 years ago

Good catch. The fetchWorkout issue had been resolved, but a recent commit made it a problem again.

In handleRouteParams, I assumed that I was only setting up the subscription to the route params, and not actually calling fetchWorkout. This will need to be changed.