Use new Reachability.internetIsReachable.
This commit is contained in:
parent
46645f700a
commit
3b59ffc446
|
@ -221,18 +221,9 @@ import Secrets
|
|||
}
|
||||
}
|
||||
|
||||
private func internetIsReachable() -> Bool {
|
||||
|
||||
guard let reachability = try? Reachability(hostname: "apple.com"), reachability.connection != .unavailable else {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
public func refreshAll(errorHandler: ((Error) -> Void)? = nil) async {
|
||||
|
||||
guard internetIsReachable() else {
|
||||
guard Reachability.internetIsReachable else {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -90,13 +90,7 @@ enum CloudKitAccountDelegateError: LocalizedError {
|
|||
|
||||
func refreshAll(for account: Account) async throws {
|
||||
|
||||
guard refreshProgress.isComplete else {
|
||||
return
|
||||
}
|
||||
|
||||
let reachability = SCNetworkReachabilityCreateWithName(nil, "apple.com")
|
||||
var flags = SCNetworkReachabilityFlags()
|
||||
guard SCNetworkReachabilityGetFlags(reachability!, &flags), flags.contains(.reachable) else {
|
||||
guard refreshProgress.isComplete, Reachability.internetIsReachable else {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,7 @@ struct CacheCleaner {
|
|||
|
||||
// If the image disk cache hasn't been flushed for 3 days and the network is available, delete it
|
||||
if flushDate.addingTimeInterval(3600 * 24 * 3) < Date() {
|
||||
if let reachability = try? Reachability(hostname: "apple.com") {
|
||||
if reachability.connection != .unavailable {
|
||||
if Reachability.internetIsReachable {
|
||||
|
||||
let tempDir = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!
|
||||
let faviconsFolderURL = tempDir.appendingPathComponent("Favicons")
|
||||
|
@ -43,11 +42,7 @@ struct CacheCleaner {
|
|||
}
|
||||
|
||||
AppDefaults.shared.lastImageCacheFlushDate = Date()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue