Comment non-working background refresh code.

This commit is contained in:
Maurice Parker 2019-04-23 17:15:19 -05:00
parent c4f624df0c
commit 84b8b04552
1 changed files with 19 additions and 21 deletions

View File

@ -89,12 +89,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
}
}
// TODO: Remove this testing code...
// AppDefaults.refreshInterval = RefreshInterval.every10Minutes
UIApplication.shared.setMinimumBackgroundFetchInterval(AppDefaults.refreshInterval.inSeconds())
// UIApplication.shared.setMinimumBackgroundFetchInterval(AppDefaults.refreshInterval.inSeconds())
NotificationCenter.default.addObserver(self, selector: #selector(accountDidDownloadArticles(_:)), name: .AccountDidDownloadArticles, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
// NotificationCenter.default.addObserver(self, selector: #selector(userDefaultsDidChange(_:)), name: UserDefaults.didChangeNotification, object: nil)
return true
@ -141,20 +139,20 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
AccountManager.shared.refreshAll()
while (!AccountManager.shared.combinedRefreshProgress.isComplete) {
sleep(1)
}
if didDownloadArticles {
completionHandler(.newData)
} else {
completionHandler(.noData)
}
}
// func application(_ application: UIApplication, performFetchWithCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
//
// AccountManager.shared.refreshAll()
// while (!AccountManager.shared.combinedRefreshProgress.isComplete) {
// sleep(1)
// }
//
// if didDownloadArticles {
// completionHandler(.newData)
// } else {
// completionHandler(.noData)
// }
//
// }
// MARK: - Split view
@ -176,9 +174,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
}
}
@objc func userDefaultsDidChange(_ note: Notification) {
UIApplication.shared.setMinimumBackgroundFetchInterval(AppDefaults.refreshInterval.inSeconds())
}
// @objc func userDefaultsDidChange(_ note: Notification) {
// UIApplication.shared.setMinimumBackgroundFetchInterval(AppDefaults.refreshInterval.inSeconds())
// }
@objc func accountDidDownloadArticles(_ note: Notification) {
didDownloadArticles = true