Skip to content

Commit

Permalink
Fix widgets recreation on app mode change
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-osm committed Oct 6, 2023
1 parent ca34397 commit b320abd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions Sources/Controllers/Map/OAMapHudViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ - (void) onApplicationModeChanged:(OAApplicationMode *)prevMode
{
dispatch_async(dispatch_get_main_queue(), ^{
[self updateColors];
[self recreateAllControls];
});
}

Expand Down
8 changes: 7 additions & 1 deletion Sources/Controllers/Map/Widgets/OAMapWidgetRegistry.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ @implementation OAMapWidgetRegistry
{
NSMutableDictionary<OAWidgetsPanel *, NSMutableOrderedSet<OAMapWidgetInfo *> *> *_allWidgets;
OAAppSettings *_settings;
OAApplicationMode *_cachedAppMode;
}

+ (OAMapWidgetRegistry *)sharedInstance
Expand Down Expand Up @@ -322,10 +323,15 @@ - (void) reorderWidgets:(NSArray<OAMapWidgetInfo *> *)widgetInfos
panels:(NSArray<OAWidgetsPanel *> *)panels
{
NSMutableArray<OAMapWidgetInfo *> *widgetInfos = [NSMutableArray array];
if (_settings.applicationMode.get == appMode)
if (_cachedAppMode == appMode)
{
[widgetInfos addObjectsFromArray:self.getAllWidgets];
}
else
{
_cachedAppMode = appMode;
[widgetInfos addObjectsFromArray:[OAWidgetsInitializer createAllControlsWithAppMode:appMode]];
}
NSMutableOrderedSet<OAMapWidgetInfo *> *filteredWidgets = [NSMutableOrderedSet orderedSet];
for (OAMapWidgetInfo *widget in widgetInfos)
{
Expand Down

0 comments on commit b320abd

Please sign in to comment.