mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
fix: changed diff calculation for BarChart value update that prevents widget redraw every time even if the value is the same as previously
This commit is contained in:
@@ -223,7 +223,13 @@ public class BarChart: WidgetWrapper {
|
||||
}
|
||||
|
||||
public func setValue(_ newValue: [[ColorValue]]) {
|
||||
guard self._value != newValue else { return }
|
||||
let tolerance: CGFloat = 0.01
|
||||
let isDifferent = self._value.count != newValue.count || zip(self._value, newValue).contains { row1, row2 in
|
||||
row1.count != row2.count || zip(row1, row2).contains { val1, val2 in
|
||||
abs(val1.value - val2.value) > tolerance || val1.color != val2.color
|
||||
}
|
||||
}
|
||||
guard isDifferent else { return }
|
||||
self._value = newValue
|
||||
DispatchQueue.main.async(execute: {
|
||||
self.display()
|
||||
|
||||
Reference in New Issue
Block a user