mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
fix: removed check if the popup is open when updating the Battery portal view (#1447)
This commit is contained in:
@@ -72,18 +72,16 @@ internal class Portal: NSStackView, Portal_p {
|
||||
|
||||
public func loadCallback(_ value: Battery_Usage) {
|
||||
DispatchQueue.main.async(execute: {
|
||||
if (self.window?.isVisible ?? false) || !self.initialized {
|
||||
self.levelField.stringValue = "\(Int(abs(value.level) * 100))%"
|
||||
|
||||
var seconds: Double = 0
|
||||
if value.timeToEmpty != -1 && value.timeToEmpty != 0 {
|
||||
seconds = Double((value.isBatteryPowered ? value.timeToEmpty : value.timeToCharge)*60)
|
||||
}
|
||||
self.timeField.stringValue = seconds != 0 ? seconds.printSecondsToHoursMinutesSeconds(short: self.timeFormat == "short") : ""
|
||||
|
||||
self.batteryView.setValue(abs(value.level))
|
||||
self.initialized = true
|
||||
self.levelField.stringValue = "\(Int(abs(value.level) * 100))%"
|
||||
|
||||
var seconds: Double = 0
|
||||
if value.timeToEmpty != -1 && value.timeToEmpty != 0 {
|
||||
seconds = Double((value.isBatteryPowered ? value.timeToEmpty : value.timeToCharge)*60)
|
||||
}
|
||||
self.timeField.stringValue = seconds != 0 ? seconds.printSecondsToHoursMinutesSeconds(short: self.timeFormat == "short") : ""
|
||||
|
||||
self.batteryView.setValue(abs(value.level))
|
||||
self.initialized = true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user