mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 15:44:32 +00:00
Something is working Finally
This commit is contained in:
parent
afda162c1f
commit
29b5111a86
10 changed files with 404 additions and 315 deletions
|
|
@ -971,7 +971,7 @@ private enum WeatherSymbolMapper {
|
|||
@MainActor
|
||||
private final class LockScreenWeatherLocationProvider: NSObject, CLLocationManagerDelegate {
|
||||
private let manager: CLLocationManager
|
||||
private var continuation: CheckedContinuation<CLLocation?, Never>?
|
||||
private var pendingContinuations: [CheckedContinuation<CLLocation?, Never>] = []
|
||||
private var lastLocation: CLLocation?
|
||||
|
||||
override init() {
|
||||
|
|
@ -997,7 +997,7 @@ private final class LockScreenWeatherLocationProvider: NSObject, CLLocationManag
|
|||
}
|
||||
manager.requestLocation()
|
||||
return await withCheckedContinuation { continuation in
|
||||
self.continuation = continuation
|
||||
self.pendingContinuations.append(continuation)
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
|
|
@ -1006,12 +1006,17 @@ private final class LockScreenWeatherLocationProvider: NSObject, CLLocationManag
|
|||
|
||||
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
|
||||
lastLocation = locations.last
|
||||
continuation?.resume(returning: lastLocation)
|
||||
continuation = nil
|
||||
flushContinuations(with: lastLocation)
|
||||
}
|
||||
|
||||
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
|
||||
continuation?.resume(returning: nil)
|
||||
continuation = nil
|
||||
flushContinuations(with: nil)
|
||||
}
|
||||
|
||||
private func flushContinuations(with location: CLLocation?) {
|
||||
guard !pendingContinuations.isEmpty else { return }
|
||||
let continuations = pendingContinuations
|
||||
pendingContinuations.removeAll()
|
||||
continuations.forEach { $0.resume(returning: location) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue