From b97850afd06a5b6bbf51b59ea17e46b73f852427 Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Wed, 10 May 2023 14:56:38 +0200 Subject: [PATCH] Fix: hide battery capacity when unknown --- assets/js/components/BatterySettingsModal.vue | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/assets/js/components/BatterySettingsModal.vue b/assets/js/components/BatterySettingsModal.vue index 7438a8aa3..d8ac84d8b 100644 --- a/assets/js/components/BatterySettingsModal.vue +++ b/assets/js/components/BatterySettingsModal.vue @@ -298,23 +298,25 @@ export default { if (!Array.isArray(this.battery)) { return; } - return this.battery.map(({ soc, capacity }) => { - const multipleBatteries = this.battery.length > 1; - const energy = this.fmtKWh( - (capacity / 100) * soc * 1e3, - true, - !multipleBatteries, - 1 - ); - const total = this.fmtKWh(capacity * 1e3, true, true, 1); - const name = multipleBatteries ? "↳ " : ""; - const formattedSoc = multipleBatteries ? ` (${this.fmtSoc(soc)})` : ""; - const formattedEnergy = this.$t("batterySettings.capacity", { - energy, - total, + return this.battery + .filter(({ capacity }) => capacity > 0) + .map(({ soc, capacity }) => { + const multipleBatteries = this.battery.length > 1; + const energy = this.fmtKWh( + (capacity / 100) * soc * 1e3, + true, + !multipleBatteries, + 1 + ); + const total = this.fmtKWh(capacity * 1e3, true, true, 1); + const name = multipleBatteries ? "↳ " : ""; + const formattedSoc = multipleBatteries ? ` (${this.fmtSoc(soc)})` : ""; + const formattedEnergy = this.$t("batterySettings.capacity", { + energy, + total, + }); + return `${name}${formattedEnergy}${formattedSoc}`; }); - return `${name}${formattedEnergy}${formattedSoc}`; - }); }, }, watch: {