@@ -20,6 +20,9 @@ import { CoreSortedDelegate } from '@classes/delegate-sorted';
2020import { makeSingleton } from '@singletons' ;
2121import { MAIN_MENU_FEATURE_PREFIX } from '../constants' ;
2222import { CoreConstants } from '@/core/constants' ;
23+ import { CoreEvents } from '@singletons/events' ;
24+ import { CoreConfigProvider } from '@services/config' ;
25+ import { CoreMainMenuOverrideItem } from './mainmenu' ;
2326
2427/**
2528 * Interface that all main menu handlers must implement.
@@ -109,6 +112,19 @@ export interface CoreMainMenuHandlerToDisplay extends CoreDelegateToDisplay, Cor
109112export class CoreMainMenuDelegateService extends CoreSortedDelegate < CoreMainMenuHandlerToDisplay , CoreMainMenuHandler > {
110113
111114 protected featurePrefix = MAIN_MENU_FEATURE_PREFIX ;
115+ protected previousEnvironment : CoreMainMenuOverrideItem [ ] = [ ] ;
116+
117+ constructor ( ) {
118+ super ( ) ;
119+
120+ CoreEvents . on ( CoreConfigProvider . ENVIRONMENT_UPDATED , ( config ) => {
121+ const newConfig = config . overrideMainMenuButtons ?? [ ] ;
122+ if ( JSON . stringify ( this . previousEnvironment ) === JSON . stringify ( newConfig ) ) {
123+ return ;
124+ }
125+ this . updateHandlers ( ) ;
126+ } ) ;
127+ }
112128
113129 /**
114130 * @inheritdoc
@@ -118,6 +134,8 @@ export class CoreMainMenuDelegateService extends CoreSortedDelegate<CoreMainMenu
118134
119135 // Override priority and icon if needed.
120136 const config = CoreConstants . CONFIG . overrideMainMenuButtons ?? [ ] ;
137+ this . previousEnvironment = config ;
138+
121139 const override = config . find ( ( entry ) => entry . handler === name ) ;
122140 if ( override ) {
123141 if ( override . priority !== undefined ) {
0 commit comments