Skip to content

Commit

Permalink
fix(ReachabilityListener): Remove background check code
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye committed Feb 24, 2025
1 parent f9664e0 commit e78d4d6
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions Sources/InfomaniakCore/Networking/ReachabilityListener.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
import Foundation
import Network

#if os(macOS)
import AppKit
#elseif os(iOS) || os(tvOS)
import UIKit
#elseif os(watchOS)
import WatchKit
#endif

@available(tvOS 12.0, watchOS 5.0, *)
public class ReachabilityListener {
public enum NetworkStatus {
case undefined
Expand Down Expand Up @@ -60,24 +51,14 @@ public class ReachabilityListener {
}

let newStatus = self.pathToStatus(path)
var inBackground = false
if !Bundle.main.isExtension {
DispatchQueue.main.sync {
#if os(macOS)
fatalError("unimplemented")
#elseif os(iOS) || os(tvOS)
inBackground = UIApplication.shared.applicationState == .background
#elseif os(watchOS)
inBackground = WKExtension.shared().applicationState == .background
#endif
}
guard newStatus != self.currentStatus else {
return
}
if newStatus != self.currentStatus && !inBackground {
self.currentStatus = newStatus
self.observersQueue.sync {
for closure in self.didChangeNetworkStatus.values {
closure(self.currentStatus)
}

self.currentStatus = newStatus
self.observersQueue.sync {
for closure in self.didChangeNetworkStatus.values {
closure(self.currentStatus)
}
}
}
Expand All @@ -99,7 +80,6 @@ public class ReachabilityListener {

// MARK: - Observation

@available(tvOS 12.0, watchOS 5.0, *)
public extension ReachabilityListener {
@discardableResult
func observeNetworkChange<T: AnyObject>(_ observer: T, using closure: @escaping (NetworkStatus) -> Void)
Expand Down

0 comments on commit e78d4d6

Please sign in to comment.