From 847a966fb7c9724388b2d3f333dd4f24ea426473 Mon Sep 17 00:00:00 2001 From: JD Hartley Date: Wed, 15 Jun 2022 19:34:05 -0700 Subject: [PATCH] Fix custom heart rate zone range display (#43) --- app/datalines/heartrate.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/datalines/heartrate.js b/app/datalines/heartrate.js index c868514..06d5060 100644 --- a/app/datalines/heartrate.js +++ b/app/datalines/heartrate.js @@ -6,6 +6,17 @@ import { user } from 'user-profile'; import Dataline from './Dataline'; import { swapClass } from '../utils'; +const ZONES = { + 'out-of-range': '', + 'fat-burn': 'fat-burn', + 'cardio': 'cardio', + 'peak': 'peak', + + 'below-custom': '', + 'custom': 'in zone', + 'above-custom': 'gt zone', +}; + export default new Dataline({ name: 'HRRT', checkPermissions() { @@ -21,10 +32,9 @@ export default new Dataline({ this.lastReadingTimestamp = this.hrm.timestamp; - const rawZone = user.heartRateZone(bpm); - const zone = (rawZone && rawZone !== 'out-of-range') ? ` ${rawZone}` : ''; + let zone = ZONES[user.heartRateZone(bpm)] || ''; - this.valueRef.text = `${bpm} bpm${zone}`; + this.valueRef.text = `${bpm} bpm ${zone}`; swapClass(this.valueRef.root, 'color', 'red'); }, start() {