From 9729bc8cd0c8d210c3089564754336fa905f6e50 Mon Sep 17 00:00:00 2001 From: Jon Ziebell Date: Tue, 24 Jan 2023 16:55:44 -0500 Subject: [PATCH] Fixed #383 - Visualize shows distance and area as "undefined/NaN" --- js/layer/load.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/js/layer/load.js b/js/layer/load.js index a7cc47d..0caeb8c 100644 --- a/js/layer/load.js +++ b/js/layer/load.js @@ -188,27 +188,27 @@ beestat.layer.load.prototype.decorate_ = function(parent) { 'USA', 'CAN' ]; + if ( - beestat.setting('units.distance') === undefined && - thermostat.address_id !== null && - beestat.address.is_valid(thermostat.address_id) === true + beestat.setting('units.distance') === undefined || + beestat.setting('units.area') === undefined ) { - const address = beestat.cache.address[thermostat.address_id]; - beestat.setting( - 'units.distance', - imperial_countries.includes(address.normalized.components.country_iso_3) === true ? 'ft' : 'm' - ); - } - if ( - beestat.setting('units.area') === undefined && - thermostat.address_id !== null && - beestat.address.is_valid(thermostat.address_id) === true - ) { - const address = beestat.cache.address[thermostat.address_id]; - beestat.setting( - 'units.area', - imperial_countries.includes(address.normalized.components.country_iso_3) === true ? 'ft²' : 'm²' - ); + if ( + thermostat.address_id !== null && + beestat.address.is_valid(thermostat.address_id) === true + ) { + const address = beestat.cache.address[thermostat.address_id]; + beestat.setting({ + 'units.distance': imperial_countries.includes(address.normalized.components.country_iso_3) === true ? 'ft' : 'm', + 'units.area': imperial_countries.includes(address.normalized.components.country_iso_3) === true ? 'ft²' : 'm²' + }); + } else { + // Assume ft/ft² if invalid address. + beestat.setting({ + 'units.distance': 'ft', + 'units.area': 'ft²' + }); + } } // Currency (USD is default)