mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-31 20:07:39 +01:00
Change to rely on application state instead of scanning scenes to determine if application is in background.
This commit is contained in:
parent
66c9d287bb
commit
90b9ab7851
@ -54,15 +54,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
var isSyncArticleStatusRunning = false
|
var isSyncArticleStatusRunning = false
|
||||||
var isWaitingForSyncTasks = false
|
var isWaitingForSyncTasks = false
|
||||||
|
|
||||||
var isAnySceneInForeground: Bool {
|
|
||||||
for scene in UIApplication.shared.connectedScenes {
|
|
||||||
if scene.activationState == .foregroundInactive || scene.activationState == .foregroundActive {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
super.init()
|
super.init()
|
||||||
appDelegate = self
|
appDelegate = self
|
||||||
@ -234,7 +225,7 @@ private extension AppDelegate {
|
|||||||
private extension AppDelegate {
|
private extension AppDelegate {
|
||||||
|
|
||||||
func waitForSyncTasksToFinish() {
|
func waitForSyncTasksToFinish() {
|
||||||
guard !isAnySceneInForeground && !isWaitingForSyncTasks else { return }
|
guard !isWaitingForSyncTasks && UIApplication.shared.applicationState == .background else { return }
|
||||||
|
|
||||||
isWaitingForSyncTasks = true
|
isWaitingForSyncTasks = true
|
||||||
|
|
||||||
@ -252,7 +243,7 @@ private extension AppDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func waitToComplete(completion: @escaping (Bool) -> Void) {
|
func waitToComplete(completion: @escaping (Bool) -> Void) {
|
||||||
guard !isAnySceneInForeground else {
|
guard UIApplication.shared.applicationState == .background else {
|
||||||
os_log("App came back to forground, no longer waiting.", log: self.log, type: .info)
|
os_log("App came back to forground, no longer waiting.", log: self.log, type: .info)
|
||||||
completion(false)
|
completion(false)
|
||||||
return
|
return
|
||||||
@ -302,7 +293,7 @@ private extension AppDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func suspendApplication() {
|
func suspendApplication() {
|
||||||
guard !isAnySceneInForeground else { return }
|
guard UIApplication.shared.applicationState == .background else { return }
|
||||||
|
|
||||||
AccountManager.shared.suspendNetworkAll()
|
AccountManager.shared.suspendNetworkAll()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user