feat: unified the logic of clocks with sensors. Now all clocks will be visible in the popup, enabling/disabling some of the clock will remove the clock from the widget (#1405)

This commit is contained in:
Serhiy Mytrovtsiy
2023-04-14 17:02:01 +02:00
parent 0e4df5dd9d
commit b2e5bbc1a6

View File

@@ -71,12 +71,14 @@ public class Clock: Module {
}
private func callback(_ value: Date) {
var clocks: [Clock_t] = self.list.filter({ $0.enabled })
var list: [Stack_t] = []
var clocks: [Clock_t] = self.list
var widgetList: [Stack_t] = []
for (i, c) in clocks.enumerated() {
clocks[i].value = value
list.append(Stack_t(key: c.name, value: clocks[i].formatted()))
if c.enabled {
widgetList.append(Stack_t(key: c.name, value: clocks[i].formatted()))
}
}
DispatchQueue.main.async(execute: {
@@ -85,7 +87,7 @@ public class Clock: Module {
self.menuBar.widgets.filter{ $0.isActive }.forEach { (w: Widget) in
switch w.item {
case let widget as SensorsWidget: widget.setValues(list)
case let widget as SensorsWidget: widget.setValues(widgetList)
default: break
}
}