Commit ddefcfb7 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

[Battery Monitor] Fix toolTipMainText when plugged in

It only had a return value for "NoCharge" since the else case was only for not plugged in, resulting in it effectively returning undefined,
throwing during assignment "cannot assign [undefined] to string" and leaving whatever text happened to be shown last.

BUG: 420920

Differential Revision: https://phabricator.kde.org/D29633
parent 19cfbb1d
......@@ -54,13 +54,17 @@ Item {
} else if (pmSource.data["Battery"]["State"] === "FullyCharged") {
return i18n("Fully Charged");
}
const percent = pmSource.data.Battery.Percent;
if (pmSource.data["AC Adapter"] && pmSource.data["AC Adapter"]["Plugged in"]) {
if (pmSource.data.Battery.State === "NoCharge") {
return i18n("Battery at %1%, not Charging", pmSource.data.Battery.Percent)
const state = pmSource.data.Battery.State;
if (state === "NoCharge") {
return i18n("Battery at %1%, not Charging", percent);
} else if (state === "Charging") {
return i18n("Battery at %1%, Charging", percent);
}
} else {
return i18n("Battery at %1%", pmSource.data.Battery.Percent);
}
return i18n("Battery at %1%", percent);
}
Plasmoid.toolTipSubText: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment