mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
feat: added a check if the macOS widget is active before updating the read value in the user defaults. It will prevent unnecessary writes when the widget is not enabled (#2733)
This commit is contained in:
@@ -234,12 +234,11 @@ public class CPU: Module {
|
||||
}
|
||||
|
||||
if #available(macOS 11.0, *) {
|
||||
if #unavailable(macOS 26.0) {
|
||||
guard let blobData = try? JSONEncoder().encode(value) else { return }
|
||||
if isWidgetActive(self.userDefaults, [CPU_entry.kind, "UnitedWidget"]), let blobData = try? JSONEncoder().encode(value) {
|
||||
self.userDefaults?.set(blobData, forKey: "CPU@LoadReader")
|
||||
WidgetCenter.shared.reloadTimelines(ofKind: CPU_entry.kind)
|
||||
WidgetCenter.shared.reloadTimelines(ofKind: "UnitedWidget")
|
||||
}
|
||||
WidgetCenter.shared.reloadTimelines(ofKind: CPU_entry.kind)
|
||||
WidgetCenter.shared.reloadTimelines(ofKind: "UnitedWidget")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user