Skip to content

Commit

Permalink
Fix custom heart rate zone range display (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhartley authored Jun 16, 2022
1 parent 615f2d6 commit 847a966
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/datalines/heartrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down

0 comments on commit 847a966

Please sign in to comment.