Fix: hide battery capacity when unknown

This commit is contained in:
Michael Geers 2023-05-10 14:56:38 +02:00
parent a1cec45c93
commit b97850afd0

View file

@ -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: {