From 5b5209d2b095e0a20f69acbbeca318bd4863051a Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 24 Jul 2024 20:39:19 -0400 Subject: [PATCH] simplify change --- MapboxCoreNavigation/RouteController.swift | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/MapboxCoreNavigation/RouteController.swift b/MapboxCoreNavigation/RouteController.swift index c3705191..b41ab25b 100644 --- a/MapboxCoreNavigation/RouteController.swift +++ b/MapboxCoreNavigation/RouteController.swift @@ -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() + } } }