modules: systemd_failed_units: Fail early if state did not change
Prefer early exit if last status matches the current status. Signed-off-by: Steffen Kothe <steffen.kothe@skothe.net>
This commit is contained in:
@ -103,6 +103,10 @@ void SystemdFailedUnits::updateData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto SystemdFailedUnits::update() -> void {
|
auto SystemdFailedUnits::update() -> void {
|
||||||
|
const std::string status = nr_failed == 0 ? "ok" : "degraded";
|
||||||
|
|
||||||
|
if (last_status == status) return;
|
||||||
|
|
||||||
// Hide if needed.
|
// Hide if needed.
|
||||||
if (nr_failed == 0 && hide_on_ok) {
|
if (nr_failed == 0 && hide_on_ok) {
|
||||||
event_box_.set_visible(false);
|
event_box_.set_visible(false);
|
||||||
@ -113,7 +117,6 @@ auto SystemdFailedUnits::update() -> void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set state class.
|
// Set state class.
|
||||||
const std::string status = nr_failed == 0 ? "ok" : "degraded";
|
|
||||||
if (!last_status.empty() && label_.get_style_context()->has_class(last_status)) {
|
if (!last_status.empty() && label_.get_style_context()->has_class(last_status)) {
|
||||||
label_.get_style_context()->remove_class(last_status);
|
label_.get_style_context()->remove_class(last_status);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user