File tree Expand file tree Collapse file tree 2 files changed +7
-20
lines changed Expand file tree Collapse file tree 2 files changed +7
-20
lines changed Original file line number Diff line number Diff line change @@ -190,19 +190,6 @@ class LastRebootMonitor {
190
190
func startMonitoring( onUpdate: @escaping ( Int ) -> Void ) {
191
191
self . updateHandler = onUpdate
192
192
193
- // Check if 24 hours have passed since the last update
194
- let lastRunKey = " LastRebootMonitorLastRun "
195
- let defaults = UserDefaults . standard
196
- let now = Date ( )
197
-
198
- if let lastRun = defaults. object ( forKey: lastRunKey) as? Date , now. timeIntervalSince ( lastRun) < 86400 {
199
- // 24 hours haven't passed, skip this run
200
- return
201
- }
202
-
203
- // Update the last run time
204
- defaults. set ( now, forKey: lastRunKey)
205
-
206
193
// Perform the reboot check
207
194
let lastRebootDays = getLastRebootDays ( )
208
195
DispatchQueue . main. async {
Original file line number Diff line number Diff line change @@ -9,7 +9,8 @@ import Foundation
9
9
import Combine
10
10
11
11
class DeviceInfoManager : ObservableObject {
12
- private var timer : AnyCancellable ?
12
+ //private var timer: AnyCancellable?
13
+ private var timer : Timer ?
13
14
14
15
static let shared = DeviceInfoManager (
15
16
deviceInfo: DeviceInfo (
@@ -34,17 +35,16 @@ class DeviceInfoManager: ObservableObject {
34
35
35
36
func startMonitoring( ) {
36
37
Logger . shared. logDebug ( " Starting device info monitoring " )
38
+ timer? . invalidate ( )
37
39
refresh ( )
38
- timer = Timer . publish ( every: 86400 , on: . main, in: . common)
39
- . autoconnect ( )
40
- . sink { _ in
41
- self . refresh ( )
42
- }
40
+ timer = Timer . scheduledTimer ( withTimeInterval: 86400 , repeats: true ) { _ in
41
+ self . refresh ( )
42
+ }
43
43
}
44
44
45
45
func stopMonitoring( ) {
46
46
Logger . shared. logDebug ( " Stopping device info monitoring " )
47
- timer? . cancel ( )
47
+ timer? . invalidate ( )
48
48
}
49
49
50
50
func refresh( ) {
You can’t perform that action at this time.
0 commit comments