Skip to content

Commit 5a0535a

Browse files
committed
Ensure at least one location; Fixes #10
1 parent 9310907 commit 5a0535a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/CLLocationManager+Promise.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ private class LocationManager: CLLocationManager, CLLocationManagerDelegate {
7070

7171
@objc fileprivate func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
7272
if let block = satisfyingBlock {
73-
let satisfiedLocations = locations.filter { block($0) == true }
74-
seal.fulfill(satisfiedLocations)
73+
let satisfiedLocations = locations.filter(block)
74+
if satisfiedLocations.count > 0 {
75+
seal.fulfill(satisfiedLocations)
76+
}
7577
} else {
7678
seal.fulfill(locations)
7779
}

0 commit comments

Comments
 (0)