@@ -107,7 +107,7 @@ public struct HubApi: Sendable {
107107 private let backgroundUncachedClient : HubClient
108108 #endif
109109
110- private let networkMonitor = NetworkMonitor ( )
110+ private let networkMonitor = NetworkMonitor . shared
111111 public typealias RepoType = Hub . RepoType
112112 public typealias Repo = Hub . Repo
113113
@@ -188,20 +188,23 @@ public struct HubApi: Sendable {
188188 useBackgroundSession: false
189189 )
190190 #if !canImport(FoundationNetworking)
191- self . backgroundCachedClient = Self . buildHubClient (
192- host: hostURL,
193- tokenProvider: tokenProvider,
194- cache: cache,
195- useBackgroundSession: true
196- )
197- self . backgroundUncachedClient = Self . buildHubClient (
198- host: hostURL,
199- tokenProvider: tokenProvider,
200- cache: nil ,
201- useBackgroundSession: true
202- )
191+ self . backgroundCachedClient =
192+ useBackgroundSession
193+ ? Self . buildHubClient (
194+ host: hostURL,
195+ tokenProvider: tokenProvider,
196+ cache: cache,
197+ useBackgroundSession: true
198+ ) : self . foregroundCachedClient
199+ self . backgroundUncachedClient =
200+ useBackgroundSession
201+ ? Self . buildHubClient (
202+ host: hostURL,
203+ tokenProvider: tokenProvider,
204+ cache: nil ,
205+ useBackgroundSession: true
206+ ) : self . foregroundUncachedClient
203207 #endif
204- NetworkMonitor . shared. startMonitoring ( )
205208 }
206209
207210 /// The shared Hub API instance with default configuration.
@@ -1144,7 +1147,7 @@ extension HubApi {
11441147
11451148 static let shared = NetworkMonitor ( )
11461149
1147- init ( ) {
1150+ private init ( ) {
11481151 #if canImport(Network)
11491152 monitor = NWPathMonitor ( )
11501153 queue = DispatchQueue ( label: " HubApi.NetworkMonitor " )
0 commit comments