Skip to content

Commit

Permalink
Update workoutSegment.js
Browse files Browse the repository at this point in the history
  • Loading branch information
JaapvanEkris authored Dec 15, 2024
1 parent c06b3cf commit d0fcedc
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions app/engine/utils/workoutSegment.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function createWorkoutSegment () {

// Returns the distance to the endpoint
function distanceToEnd (baseMetrics) {
if (_endDistance > 0) {
if (_type === 'distance' && _endDistance > 0) {
// We have exceeded the boundary
return _endDistance - baseMetrics.totalLinearDistance
} else {
Expand All @@ -127,7 +127,7 @@ export function createWorkoutSegment () {

// Returns the time to the endpoint
function timeToEnd (baseMetrics) {
if (_endTime > 0) {
if (_type === 'time' && _endTime > 0) {
// We have exceeded the boundary
return _endTime - baseMetrics.totalMovingTime
} else {
Expand Down Expand Up @@ -205,23 +205,41 @@ export function createWorkoutSegment () {
}

function endDistance () {
return _endDistance
if (_type === 'distance' && _endDistance > 0) {
return _endDistance
} else {
return undefined
}
}

function endTime () {
return _endTime
if (_type === 'time' && _endTime > 0) {
// We have exceeded the boundary
return _endTime
} else {
return undefined
}
}

function getSplit () {
return _split
}

function targetDistance () {
return _targetDistance
if (_type === 'distance' && _endDistance > 0) {
return _targetDistance
} else {
return undefined
}
}

function targetTime () {
return _targetTime
if (_type === 'time' && _endTime > 0) {
// We have exceeded the boundary
return _targetTime
} else {
return undefined
}
}

function splitDistance () {
Expand Down

0 comments on commit d0fcedc

Please sign in to comment.