Skip to content

Commit

Permalink
simplify change
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkirk committed Jul 25, 2024
1 parent 85a3018 commit 5b5209d
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions MapboxCoreNavigation/RouteController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -429,23 +429,22 @@ extension RouteController: CLLocationManagerDelegate {

func updateRouteLegProgress(for location: CLLocation) {
let currentDestination = self.routeProgress.currentLeg.destination
guard self.routeProgress.currentLegProgress.remainingSteps.count == 0 else { return }

if let remainingSpokenInstructions = routeProgress.currentLegProgress.currentStepProgress.remainingSpokenInstructions {
guard remainingSpokenInstructions.count == 0 else { return }
var hasRemainingVoiceInstructions = false
if let remainingVoiceInstructions = routeProgress.currentLegProgress.currentStepProgress.remainingSpokenInstructions, remainingVoiceInstructions.count > 0 {
hasRemainingVoiceInstructions = true
}

guard currentDestination != self.previousArrivalWaypoint else { return }

self.previousArrivalWaypoint = currentDestination
if self.routeProgress.currentLegProgress.remainingSteps.count <= 1, !hasRemainingVoiceInstructions, currentDestination != self.previousArrivalWaypoint {
self.previousArrivalWaypoint = currentDestination

self.routeProgress.currentLegProgress.userHasArrivedAtWaypoint = true
self.routeProgress.currentLegProgress.userHasArrivedAtWaypoint = true

let advancesToNextLeg = self.delegate?.routeController?(self, didArriveAt: currentDestination) ?? true
let advancesToNextLeg = self.delegate?.routeController?(self, didArriveAt: currentDestination) ?? true

if !self.routeProgress.isFinalLeg, advancesToNextLeg {
self.routeProgress.legIndex += 1
self.updateDistanceToManeuver()
if !self.routeProgress.isFinalLeg, advancesToNextLeg {
self.routeProgress.legIndex += 1
self.updateDistanceToManeuver()
}
}
}

Expand Down

0 comments on commit 5b5209d

Please sign in to comment.