Dealt with an edge case

Dealt with an edge case where there are no strokes detected, but a number of impulses is recorded (Typically during first calibration).
This commit is contained in:
Jaap van Ekris 2023-03-02 11:25:20 +01:00 committed by GitHub
parent 65b273bbea
commit 97c1da96d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -311,8 +311,12 @@ function createWorkoutRecorder () {
function minimumRecordingTimeHasPassed () {
const minimumRecordingTimeInSeconds = 10
const rotationImpulseTimeTotal = rotationImpulses.reduce((acc, impulse) => acc + impulse, 0)
const strokeTimeTotal = strokes[strokes.length - 1].totalMovingTime
return (Math.max(rotationImpulseTimeTotal, strokeTimeTotal) > minimumRecordingTimeInSeconds)
if (strokes.length > 0) {
const strokeTimeTotal = strokes[strokes.length - 1].totalMovingTime
return (Math.max(rotationImpulseTimeTotal, strokeTimeTotal) > minimumRecordingTimeInSeconds)
} else {
return (rotationImpulseTimeTotal > minimumRecordingTimeInSeconds)
}
}
return {