I'm not the hottest JS coder, so excuse me if I am misunderstanding this, but when I sync a Strength activity that includes exercise sets where the first set is a REST (I think I did this because I paused the activity before actually starting), the web interface crashes (and so does the Android app);
In https://connect.garmin.com/web-react/static/js/backbone/models/activity/RepCountingActivity.js line 154 -
getConsolidatedJSON: function() {
var allSets = this.get('exerciseSets'),
restTime = 0,
sets = [],
that = this;
_.each(allSets, function(set) {
if (set.setType === 'REST') {
if (!sets[sets.length - 1].rest) { <====== this is the error line
sets[sets.length - 1].rest = 0;
}
sets[sets.length - 1].rest += set.duration;
} else {
set.exerciseType = that.getExerciseType(set.exercises);
sets.push(set);
}
});
return sets;
},
Then, with this data set (truncated!):
{"activityId":4172875329,"exerciseSets":[{"exercises":[],"duration":4.416,"repetitionCount":null,"weight":null,"setType":"REST","startTime":"2019-10-19T12:46:29.0","wktStepIndex":null},{"exercises":[{"category":"UNKNOWN","name":null,"probability":99.609375},{"category":"CURL","name":null,"probability":0.0},{"category":"BENCH_PRESS","name":null,"probability":0.0}],"duration":26.901,"repetitionCount":20,"weight":39000.0,"setType":"ACTIVE","startTime":"2019-10-19T12:46:33.0","wktStepIndex":null},{"exercises":[],"duration":59.56,"repetitionCount":null,"weight":null,"setType":"REST","startTime":"2019-10-19T12:47:00.0","wktStepIndex":null},{"exercises":[{"category":"UNKNOWN","name":null,"probability":99.609375},{"category":"CURL","name":null,"probability":0.0},{"category":"BENCH_PRESS","name":null,"probability":0.0}],"duration":35.358,"repetitionCount":15,"weight":45000.0,"setType":"ACTIVE","startTime":"2019-10-19T12:47:59.0","wktStepIndex":null},
the when sets[] is empty, sets.length - 1 is < 0 and you get an error:
RepCountingActivity.js:154 Uncaught TypeError: Cannot read property 'rest' of undefined
at RepCountingActivity.js:154
at Function.v.each.v.forEach (underscore.js:153)
at r.getConsolidatedJSON (RepCountingActivity.js:152)
at renderSets (EditRepCountingActivityView.js:83)
at render (EditRepCountingActivityView.js:54)
at r.showRepCountingElements (EditActivityPageView.js:640)
at render (EditActivityPageView.js:507)
at r.<anonymous> (PageView.js:89)
at A (underscore.js:701)
at r.i [as render] (underscore.js:733)
Someone, assuming my JS is not completely mistaken (and it could be) needs to check for the empty set first.
When my activities don't start with a "REST" then all seems OK.