fix: prevent time remaining showing 0 after unplugging

This commit is contained in:
Jonathan Capps 2025-03-15 18:02:58 +00:00 • committed by Michael Murphy
parent 25064dff8a
commit e55d59ed94

View file

@ -504,7 +504,8 @@ impl cosmic::Application for CosmicBatteryApplet {
} = theme::active().cosmic().spacing; } = theme::active().cosmic().spacing;
let name = text::body(fl!("battery")); let name = text::body(fl!("battery"));
let description = text::caption(if !self.on_battery { let description = text::caption(
if !self.on_battery || self.time_remaining == Duration::from_secs(0u64) {
format!("{:.0}%", self.battery_percent) format!("{:.0}%", self.battery_percent)
} else { } else {
format!( format!(
@ -513,7 +514,8 @@ impl cosmic::Application for CosmicBatteryApplet {
fl!("until-empty"), fl!("until-empty"),
self.battery_percent self.battery_percent
) )
}); },
);
let mut content = vec![ let mut content = vec![
padded_control( padded_control(