Update to accurately report if data was received during background fetch or not.
This commit is contained in:
parent
284e713a9d
commit
7392d6111a
|
@ -141,6 +141,15 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
||||||
|
|
||||||
os_log("Woken to perform account refresh.", log: log, type: .info)
|
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()
|
AccountManager.shared.refreshAll()
|
||||||
|
|
||||||
os_log("Accounts requested to begin refresh.", log: self.log, type: .debug)
|
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 {
|
self.backgroundUpdateTask = UIApplication.shared.beginBackgroundTask {
|
||||||
UIApplication.shared.endBackgroundTask(self.backgroundUpdateTask)
|
UIApplication.shared.endBackgroundTask(self.backgroundUpdateTask)
|
||||||
self.backgroundUpdateTask = UIBackgroundTaskIdentifier.invalid
|
self.backgroundUpdateTask = UIBackgroundTaskIdentifier.invalid
|
||||||
completionHandler(.newData)
|
updateCompletionHandler()
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
@ -163,12 +172,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UISplitViewControllerDele
|
||||||
|
|
||||||
UIApplication.shared.endBackgroundTask(self.backgroundUpdateTask)
|
UIApplication.shared.endBackgroundTask(self.backgroundUpdateTask)
|
||||||
self.backgroundUpdateTask = UIBackgroundTaskIdentifier.invalid
|
self.backgroundUpdateTask = UIBackgroundTaskIdentifier.invalid
|
||||||
completionHandler(.newData)
|
updateCompletionHandler()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
completionHandler(.newData)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Split view
|
// MARK: - Split view
|
||||||
|
|
Loading…
Reference in New Issue