diff --git a/iphone/Maps/Core/Routing/MWMRouter.mm b/iphone/Maps/Core/Routing/MWMRouter.mm index 8f986da84..e1acb63ef 100644 --- a/iphone/Maps/Core/Routing/MWMRouter.mm +++ b/iphone/Maps/Core/Routing/MWMRouter.mm @@ -146,6 +146,10 @@ char const *kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeIm _canAutoAddLastLocation = YES; _routingOptions = [MWMRoutingOptions new]; _isRestoreProcessCompleted = NO; + + [NSNotificationCenter.defaultCenter addObserverForName:@"RoutingOptionsChanged" object:nil queue:nil usingBlock:^(NSNotification * _Nonnull notification) { + [MWMRouter updateRoute]; + }]; } return self; } @@ -570,7 +574,7 @@ char const *kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeIm + (void)updateRoute { MWMRoutingOptions *newOptions = [MWMRoutingOptions new]; - if ((self.isRoutingActive && !self.isOnRoute) && ![newOptions isEqual:[self router].routingOptions]) { + if (self.isRoutingActive && !self.isOnRoute && ![newOptions isEqual:[self router].routingOptions]) { [self rebuildWithBestRouter:YES]; } } diff --git a/iphone/Maps/Model/Settings.swift b/iphone/Maps/Model/Settings.swift index d04623fb2..ba008c58e 100644 --- a/iphone/Maps/Model/Settings.swift +++ b/iphone/Maps/Model/Settings.swift @@ -4,6 +4,10 @@ import Combine @objc class Settings: NSObject { // MARK: Properties + // The notification name for changed routing options + static let routingOptionsChangedNotificationName: Notification.Name = Notification.Name(rawValue: "RoutingOptionsChanged") + + /// Key for storing if the sync beta alert has been shown in the user defaults static private let userDefaultsKeyHasShownSyncBetaAlert = "kUDDidShowICloudSynchronizationEnablingAlert" @@ -352,6 +356,8 @@ import Combine let routingOptions = RoutingOptions() routingOptions.avoidToll = newValue routingOptions.save() + + NotificationCenter.default.post(name: routingOptionsChangedNotificationName, object: nil) } } @@ -365,6 +371,8 @@ import Combine let routingOptions = RoutingOptions() routingOptions.avoidDirty = newValue routingOptions.save() + + NotificationCenter.default.post(name: routingOptionsChangedNotificationName, object: nil) } } @@ -378,6 +386,8 @@ import Combine let routingOptions = RoutingOptions() routingOptions.avoidFerry = newValue routingOptions.save() + + NotificationCenter.default.post(name: routingOptionsChangedNotificationName, object: nil) } } @@ -391,6 +401,8 @@ import Combine let routingOptions = RoutingOptions() routingOptions.avoidMotorway = newValue routingOptions.save() + + NotificationCenter.default.post(name: routingOptionsChangedNotificationName, object: nil) } }