Skip to content

Commit 2a16848

Browse files
authored
Update workoutSegment.js
1 parent bac6e02 commit 2a16848

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/engine/utils/workoutSegment.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export function createWorkoutSegment () {
1919
}
2020

2121
function setStart (baseMetrics) {
22-
_startTime = baseMetrics.totalMovingTime
23-
_startDistance = baseMetrics.totalLinearDistance
22+
_startTime = (baseMetrics.totalMovingTime !== undefined && baseMetrics.totalMovingTime > 0 ? baseMetrics.totalMovingTime : 0)
23+
_startDistance = (baseMetrics.totalLinearDistance !== undefined && baseMetrics.totalLinearDistance > 0 ? baseMetrics.totalLinearDistance : 0)
2424
_type = 'justrow'
25+
_targetTime = 0
26+
_targetDistance = 0
2527
_endTime = 0
2628
_endDistance = 0
2729
_split = {
@@ -135,7 +137,7 @@ export function createWorkoutSegment () {
135137

136138
// Checks for reaching a boundary condition
137139
function isEndReached (baseMetrics) {
138-
if ((_endDistance > 0 && baseMetrics.totalLinearDistance >= _endDistance) || (_endTime > 0 && baseMetrics.totalMovingTime >= _endTime)) {
140+
if ((_type === 'distance' && _endDistance > 0 && baseMetrics.totalLinearDistance >= _endDistance) || (_type === 'time' && _endTime > 0 && baseMetrics.totalMovingTime >= _endTime)) {
139141
// We have exceeded the boundary
140142
return true
141143
} else {

0 commit comments

Comments
 (0)