From b320abdb5f5fecae014af0a04a94cd5683adb272 Mon Sep 17 00:00:00 2001 From: alex-osm Date: Fri, 6 Oct 2023 12:23:41 +0300 Subject: [PATCH] Fix widgets recreation on app mode change --- Sources/Controllers/Map/OAMapHudViewController.mm | 1 + Sources/Controllers/Map/Widgets/OAMapWidgetRegistry.mm | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/Controllers/Map/OAMapHudViewController.mm b/Sources/Controllers/Map/OAMapHudViewController.mm index 58e7c1f2bc..1b62029e76 100644 --- a/Sources/Controllers/Map/OAMapHudViewController.mm +++ b/Sources/Controllers/Map/OAMapHudViewController.mm @@ -696,6 +696,7 @@ - (void) onApplicationModeChanged:(OAApplicationMode *)prevMode { dispatch_async(dispatch_get_main_queue(), ^{ [self updateColors]; + [self recreateAllControls]; }); } diff --git a/Sources/Controllers/Map/Widgets/OAMapWidgetRegistry.mm b/Sources/Controllers/Map/Widgets/OAMapWidgetRegistry.mm index 2877eb9bd2..d8dd36db92 100644 --- a/Sources/Controllers/Map/Widgets/OAMapWidgetRegistry.mm +++ b/Sources/Controllers/Map/Widgets/OAMapWidgetRegistry.mm @@ -25,6 +25,7 @@ @implementation OAMapWidgetRegistry { NSMutableDictionary *> *_allWidgets; OAAppSettings *_settings; + OAApplicationMode *_cachedAppMode; } + (OAMapWidgetRegistry *)sharedInstance @@ -322,10 +323,15 @@ - (void) reorderWidgets:(NSArray *)widgetInfos panels:(NSArray *)panels { NSMutableArray *widgetInfos = [NSMutableArray array]; - if (_settings.applicationMode.get == appMode) + if (_cachedAppMode == appMode) + { [widgetInfos addObjectsFromArray:self.getAllWidgets]; + } else + { + _cachedAppMode = appMode; [widgetInfos addObjectsFromArray:[OAWidgetsInitializer createAllControlsWithAppMode:appMode]]; + } NSMutableOrderedSet *filteredWidgets = [NSMutableOrderedSet orderedSet]; for (OAMapWidgetInfo *widget in widgetInfos) {