wait till all deviceInfos are collected before checking length

This commit is contained in:
Jason Calabrese
2016-12-12 00:08:21 -08:00
parent efe69e5095
commit 6032c8f8cd
+12 -10
View File
@@ -194,7 +194,7 @@ function init (ctx) {
var deviceInfos = { };
if (prop.sgvs && prop.sgvs.length > 1) {
if (prop.sgvs) {
_.forEach(prop.sgvs, function deviceAndValue(entry) {
var device = utils.deviceName(entry.device);
deviceInfos[device] = {
@@ -205,7 +205,7 @@ function init (ctx) {
});
}
if (delta && delta.previous && delta.previous.sgvs && delta.previous.sgvs.length > 1) {
if (delta && delta.previous && delta.previous.sgvs) {
_.forEach(delta.previous.sgvs, function deviceAndValue(entry) {
var device = utils.deviceName(entry.device);
var deviceInfo = deviceInfos[device];
@@ -227,16 +227,18 @@ function init (ctx) {
}
});
_.forIn(deviceInfos, function addInfo (deviceInfo, name) {
var display = deviceInfo.value;
if (deviceInfo.delta) {
display += ' ' + deviceInfo.delta;
}
if (_.keys(deviceInfos).length > 1) {
_.forIn(deviceInfos, function addInfo(deviceInfo, name) {
var display = deviceInfo.value;
if (deviceInfo.delta) {
display += ' ' + deviceInfo.delta;
}
display += ' (' + deviceInfo.time + ')';
display += ' (' + deviceInfo.time + ')';
info.push({label: name, value: display});
});
info.push({label: name, value: display});
});
}
}
sbx.pluginBase.updatePillText({