nkfoss / ohm-str

0 stars 0 forks source link

Add snackbar to confirm save-workout success/failure #31

Closed nkfoss closed 4 years ago

michael-small commented 4 years ago

One error: see "Sep 05, 2020" for example.

There is a bench press entry with no weight, reps, or proportion of effort. When clicking "Save Workout", there is the following error because there are no data points:

core.js:4080 ERROR TypeError: Cannot read property 'length' of undefined
    at repmax.service.ts:77
    at Array.forEach (<anonymous>)
    at RepmaxService.push../src/app/repmax.service.ts.RepmaxService.patchDayMaxes (repmax.service.ts:75)
    at SetListComponent.push../src/app/sets/setList/setList.component.ts.SetListComponent.onSaveWorkout (setList.component.ts:86)
    at SetListComponent_Template_button_click_7_listener (template.html:34)
    at executeListenerWithErrorHandling (core.js:15026)
    at wrapListenerIn_markDirtyAndPreventDefault (core.js:15061)
    at HTMLButtonElement.<anonymous> (platform-browser.js:615)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:28233)

This happens on any day with an entry that is missing things like reps. In particular, repmax.service.ts:77 refers to

if (exercise.sets.length < 1 || exercise.setType === "clusters") { return; }

However, it seems to save the entry anyways.

nkfoss commented 4 years ago

Moving forward, this going to be implemented similarly to how errors are handled by the auth service. The method will expect to catch an error, then outsource it to another method to handle. The setlist component will also set up a subscription and subscribe to the service's method, and then handle the response (or error message) appropriately.