Update to accurately report if data was received during background fetch or not.

This commit is contained in:
Maurice Parker 2019-04-26 09:42:00 -05:00
parent 284e713a9d
commit 7392d6111a
1 changed files with 12 additions and 5 deletions

View File

@ -141,6 +141,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
os_log("Woken to perform account refresh.", log: log, type: .info)
let startingUnreadCount = unreadCount
let updateCompletionHandler = { [unowned self] in
if startingUnreadCount != self.unreadCount {
completionHandler(.newData)
} else {
completionHandler(.noData)
}
}
AccountManager.shared.refreshAll()
os_log("Accounts requested to begin refresh.", log: self.log, type: .debug)
@ -150,7 +159,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
self.backgroundUpdateTask = UIApplication.shared.beginBackgroundTask {
UIApplication.shared.endBackgroundTask(self.backgroundUpdateTask)
self.backgroundUpdateTask = UIBackgroundTaskIdentifier.invalid
completionHandler(.newData)
updateCompletionHandler()
}
sleep(1)
@ -163,12 +172,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
UIApplication.shared.endBackgroundTask(self.backgroundUpdateTask)
self.backgroundUpdateTask = UIBackgroundTaskIdentifier.invalid
completionHandler(.newData)
updateCompletionHandler()
}
completionHandler(.newData)
}
// MARK: - Split view