Skip to content

Commit

Permalink
Merge pull request #9 from flitsmeister/feature/fix-spammy-shizzle
Browse files Browse the repository at this point in the history
Fixed spammy when server doesn't respond
  • Loading branch information
Svantulden authored Jul 6, 2020
2 parents d334f1a + b7bd1e9 commit b48eac3
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Examples/Objective-CTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleVersion</key>
<string>34</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Examples/SwiftTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleVersion</key>
<string>34</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion MapboxCoreNavigation/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleVersion</key>
<string>34</string>
<key>NSPrincipalClass</key>
Expand Down
17 changes: 15 additions & 2 deletions MapboxCoreNavigation/RouteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ open class RouteController: NSObject, Router {

var isRerouting = false
var lastRerouteLocation: CLLocation?

var isFindingFasterRoute = false

var routeTask: URLSessionDataTask?
var lastLocationDate: Date?
Expand Down Expand Up @@ -425,6 +427,10 @@ extension RouteController: CLLocationManagerDelegate {
}

func checkForFasterRoute(from location: CLLocation) {
guard !isFindingFasterRoute else {
return
}

guard let currentUpcomingManeuver = routeProgress.currentLegProgress.upComingStep else {
return
}
Expand All @@ -439,18 +445,25 @@ extension RouteController: CLLocationManagerDelegate {
return
}
let durationRemaining = routeProgress.durationRemaining

isFindingFasterRoute = true

getDirections(from: location, along: routeProgress) { [weak self] (route, error) in
guard let strongSelf = self else {
return
}

// Every request should reset the lastLocationDate, else we spam the server by calling this method every location update.
// If the call fails, tough luck buddy! Then wait until the next interval before retrying
strongSelf.lastLocationDate = nil

// Also only do one 'findFasterRoute' call per time
strongSelf.isFindingFasterRoute = false

guard let route = route else {
return
}

strongSelf.lastLocationDate = nil

guard let firstLeg = route.legs.first, let firstStep = firstLeg.steps.first else {
return
}
Expand Down
2 changes: 1 addition & 1 deletion MapboxCoreNavigationTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location Usage Description</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigation/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleVersion</key>
<string>34</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion MapboxNavigationTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Location Usage Description</string>
<key>NSLocationWhenInUseUsageDescription</key>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Alternatively, to install Mapbox Navigation using [Carthage](https://github.com/

1. Create a [Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#github-repositories) with the following dependency:
```cartfile
github "flitsmeister/flitsmeister-navigation-ios" ~> 1.0.2
github "flitsmeister/flitsmeister-navigation-ios" ~> 1.0.3
```

1. Run `carthage update --platform iOS` to build just the iOS dependencies.
Expand Down
2 changes: 1 addition & 1 deletion RouteTest/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleVersion</key>
<string>34</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
4 changes: 2 additions & 2 deletions custom-navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To install Mapbox Core Navigation using [CocoaPods](https://cocoapods.org/):

1. Specify the following dependency in your Podfile:
```ruby
pod 'MapboxCoreNavigation', '~> 1.0.2'
pod 'MapboxCoreNavigation', '~> 1.0.3'
```

1. Run `pod install` and open the resulting Xcode workspace.
Expand All @@ -31,7 +31,7 @@ Alternatively, to install Mapbox Core Navigation using [Carthage](https://github
1. Specify the following dependency in your Cartfile:
```cartfile
github "mapbox/mapbox-navigation-ios" ~> 1.0.2
github "mapbox/mapbox-navigation-ios" ~> 1.0.3
```
1. Run `carthage update --platform iOS` to build just the iOS dependencies.
Expand Down

0 comments on commit b48eac3

Please sign in to comment.