mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +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:
@@ -39,8 +39,9 @@ public struct Provider: TimelineProvider {
|
||||
}
|
||||
|
||||
public func getTimeline(in context: Context, completion: @escaping (Timeline<CPU_entry>) -> Void) {
|
||||
self.userDefaults?.set(Date().timeIntervalSince1970, forKey: CPU_entry.kind)
|
||||
var entry = CPU_entry()
|
||||
if let raw = userDefaults?.data(forKey: "CPU@LoadReader"), let load = try? JSONDecoder().decode(CPU_Load.self, from: raw) {
|
||||
if let raw = self.userDefaults?.data(forKey: "CPU@LoadReader"), let load = try? JSONDecoder().decode(CPU_Load.self, from: raw) {
|
||||
entry.value = load
|
||||
}
|
||||
let entries: [CPU_entry] = [entry]
|
||||
|
||||
Reference in New Issue
Block a user