Skip to content

Commit

Permalink
show last carbs even if careportal cob is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncalabrese committed Dec 20, 2016
1 parent 3172c82 commit d49319b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions lib/plugins/cob.js
Expand Up @@ -48,7 +48,7 @@ function init(ctx) {
if (_.isEmpty(result)) {
result = treatmentCOB;
result.source = 'Care Portal';
} else if (treatmentCOB.cob) {
} else if (treatmentCOB) {
result.treatmentCOB = treatmentCOB;
}

Expand Down Expand Up @@ -252,16 +252,16 @@ function init(ctx) {

var displayCob = Math.round(prop.cob * 10) / 10;

var info = null;
if (prop.treatmentCOB !== undefined) {
info = [ ];
var info = [ ];
if (prop.treatmentCOB !== undefined && prop.treatmentCOB.cob) {
info.push({label: translate('Careportal COB'), value: Math.round(prop.treatmentCOB.cob * 10) / 10});
}

if (prop.treatmentCOB.lastCarbs) {
var when = new Date(prop.treatmentCOB.lastCarbs.mills).toLocaleString();
var amount = prop.treatmentCOB.lastCarbs.carbs + 'g';
info.push({label: translate('Last Carbs'), value: amount + ' @ ' + when});
}
var lastCarbs = prop.lastCarbs || (prop.treatmentCOB && prop.treatmentCOB.lastCarbs);
if (lastCarbs) {
var when = new Date(lastCarbs.mills).toLocaleString();
var amount = lastCarbs.carbs + 'g';
info.push({label: translate('Last Carbs'), value: amount + ' @ ' + when});
}

sbx.pluginBase.updatePillText(sbx, {
Expand Down

0 comments on commit d49319b

Please sign in to comment.