From e4b27a27c53fed8a3dab60c8280e9c4b7e26326d Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 6 Oct 2020 19:42:34 -0500 Subject: [PATCH] Change so that we don't try to sync if the network is unavailable. Issue #2262 --- Account/Sources/Account/AccountManager.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Account/Sources/Account/AccountManager.swift b/Account/Sources/Account/AccountManager.swift index b71e981be..3f517cf6d 100644 --- a/Account/Sources/Account/AccountManager.swift +++ b/Account/Sources/Account/AccountManager.swift @@ -8,6 +8,7 @@ import Foundation import RSCore +import RSWeb import Articles import ArticlesDatabase @@ -228,6 +229,8 @@ public final class AccountManager: UnreadCountProvider { } public func refreshAll(errorHandler: @escaping (Error) -> Void, completion: (() -> Void)? = nil) { + guard let reachability = try? Reachability(hostname: "apple.com"), reachability.connection != .unavailable else { return } + let group = DispatchGroup() activeAccounts.forEach { account in @@ -249,6 +252,8 @@ public final class AccountManager: UnreadCountProvider { } public func refreshAll(completion: (() -> Void)? = nil) { + guard let reachability = try? Reachability(hostname: "apple.com"), reachability.connection != .unavailable else { return } + var syncErrors = [AccountSyncError]() let group = DispatchGroup()