Create ArticleStatusSyncTimer.shared.

This commit is contained in:
Brent Simmons
2025-02-01 20:03:01 -08:00
parent 3bd8ce573f
commit 69e52dd90a
3 changed files with 19 additions and 24 deletions

View File

@@ -23,17 +23,6 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
private var coordinator: SceneCoordinator?
var syncTimer: ArticleStatusSyncTimer?
private var shuttingDown = false {
didSet {
if shuttingDown {
syncTimer?.shuttingDown = shuttingDown
syncTimer?.invalidate()
}
}
}
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "Application")
var userNotificationManager: UserNotificationManager!
@@ -106,10 +95,10 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
widgetDataEncoder = WidgetDataEncoder()
syncTimer = ArticleStatusSyncTimer()
_ = ArticleStatusSyncTimer.shared
#if DEBUG
syncTimer!.update()
ArticleStatusSyncTimer.shared.update()
#endif
// Create window.
@@ -156,7 +145,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
}
func applicationWillTerminate(_ application: UIApplication) {
shuttingDown = true
ArticleStatusSyncTimer.shared.stop()
}
func applicationDidEnterBackground(_ application: UIApplication) {
@@ -199,7 +188,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
func prepareAccountsForBackground() {
extensionFeedAddRequestFile.suspend()
syncTimer?.invalidate()
ArticleStatusSyncTimer.shared.invalidate()
scheduleBackgroundFeedRefresh()
syncArticleStatus()
widgetDataEncoder.encode()
@@ -208,7 +197,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationC
func prepareAccountsForForeground() {
extensionFeedAddRequestFile.resume()
syncTimer?.update()
ArticleStatusSyncTimer.shared.update()
if let lastRefresh = AppDefaults.lastRefresh {
if Date() > lastRefresh.addingTimeInterval(15 * 60) {