Skip to content

Commit 20b4354

Browse files
committed
ci part 2
1 parent 453cccc commit 20b4354

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

Sources/Daycal/CalendarStore.swift

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,30 @@ final class CalendarStore: ObservableObject {
134134

135135
private func startNetworkMonitoring() {
136136
pathMonitor.pathUpdateHandler = { [weak self] path in
137+
guard let self else { return }
137138
Task { @MainActor in
138-
guard let self else { return }
139-
let online = path.status == .satisfied
140-
guard online != self.isOnline else { return }
141-
self.isOnline = online
142-
143-
if online {
144-
if self.authState == .offline {
145-
self.authState = .signedIn
146-
}
147-
await self.refreshEvents()
148-
self.scheduleAutoRefresh()
149-
} else if self.authState == .signedIn {
150-
self.authState = .offline
151-
}
139+
await self.handlePathUpdate(path)
152140
}
153141
}
154142
pathMonitor.start(queue: pathMonitorQueue)
155143
}
156144

145+
private func handlePathUpdate(_ path: NWPath) async {
146+
let online = path.status == .satisfied
147+
guard online != isOnline else { return }
148+
isOnline = online
149+
150+
if online {
151+
if authState == .offline {
152+
authState = .signedIn
153+
}
154+
await refreshEvents()
155+
scheduleAutoRefresh()
156+
} else if authState == .signedIn {
157+
authState = .offline
158+
}
159+
}
160+
157161
private func isOfflineError(_ error: Error) -> Bool {
158162
guard let urlError = error as? URLError else { return false }
159163
switch urlError.code {

0 commit comments

Comments
 (0)