diff --git a/src/addons/notifications/pages/settings/settings.ts b/src/addons/notifications/pages/settings/settings.ts
index f3e8189c0..fd24867d5 100644
--- a/src/addons/notifications/pages/settings/settings.ts
+++ b/src/addons/notifications/pages/settings/settings.ts
@@ -37,7 +37,7 @@ import {
AddonNotificationsPreferencesNotificationFormatted,
AddonNotificationsPreferencesProcessorFormatted,
} from '@addons/notifications/services/notifications-helper';
-import { CoreNavHelper } from '@services/nav-helper';
+import { CoreNavigator } from '@services/navigator';
// import { CoreSplitViewComponent } from '@components/split-view/split-view';
/**
@@ -201,7 +201,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy {
openExtraPreferences(handlerData: AddonMessageOutputHandlerData): void {
// Decide which navCtrl to use. If this page is inside a split view, use the split view's master nav.
// @todo const navCtrl = this.svComponent ? this.svComponent.getMasterNav() : this.navCtrl;
- CoreNavHelper.instance.goInCurrentMainMenuTab(handlerData.page, handlerData.pageParams);
+ CoreNavigator.instance.navigateToSitePath(handlerData.page, { params: handlerData.pageParams });
}
/**
diff --git a/src/addons/notifications/services/handlers/push-click.ts b/src/addons/notifications/services/handlers/push-click.ts
index 7e731e421..8b8e00723 100644
--- a/src/addons/notifications/services/handlers/push-click.ts
+++ b/src/addons/notifications/services/handlers/push-click.ts
@@ -14,7 +14,7 @@
import { Injectable } from '@angular/core';
-import { CoreNavHelper } from '@services/nav-helper';
+import { CoreNavigator } from '@services/navigator';
import { CoreTextUtils } from '@services/utils/text';
import { CoreUtils } from '@services/utils/utils';
import { makeSingleton } from '@singletons';
@@ -23,6 +23,7 @@ import { CorePushNotificationsClickHandler } from '@features/pushnotifications/s
import { CorePushNotificationsNotificationBasicData } from '@features/pushnotifications/services/pushnotifications';
import { CoreContentLinksHelper } from '@features/contentlinks/services/contentlinks-helper';
import { AddonNotifications, AddonNotificationsProvider } from '../notifications';
+import { AddonNotificationsMainMenuHandlerService } from './mainmenu';
/**
* Handler for non-messaging push notifications clicks.
@@ -122,7 +123,10 @@ export class AddonNotificationsPushClickHandlerService implements CorePushNotifi
// No contexturl or cannot be handled by the app. Open the notifications page.
await CoreUtils.instance.ignoreErrors(AddonNotifications.instance.invalidateNotificationsList(notification.site));
- await CoreNavHelper.instance.goInSite('notifications', {}, notification.site);
+ await CoreNavigator.instance.navigateToSitePath(
+ AddonNotificationsMainMenuHandlerService.PAGE_NAME,
+ { siteId: notification.site },
+ );
}
}
diff --git a/src/core/features/mainmenu/mainmenu-lazy.module.ts b/src/core/features/mainmenu/mainmenu-lazy.module.ts
index 03464fccf..16a1171a1 100644
--- a/src/core/features/mainmenu/mainmenu-lazy.module.ts
+++ b/src/core/features/mainmenu/mainmenu-lazy.module.ts
@@ -24,6 +24,7 @@ import { resolveModuleRoutes } from '@/app/app-routing.module';
import { MAIN_MENU_ROUTES } from './mainmenu-routing.module';
import { CoreMainMenuPage } from './pages/menu/menu';
import { CoreMainMenuHomeHandlerService } from './services/handlers/mainmenu';
+import { CoreMainMenuProvider } from './services/mainmenu';
function buildRoutes(injector: Injector): Routes {
const routes = resolveModuleRoutes(injector, MAIN_MENU_ROUTES);
@@ -43,7 +44,7 @@ function buildRoutes(injector: Injector): Routes {
loadChildren: () => import('./pages/home/home.module').then(m => m.CoreMainMenuHomePageModule),
},
{
- path: 'more',
+ path: CoreMainMenuProvider.MORE_PAGE_NAME,
loadChildren: () => import('./pages/more/more.module').then(m => m.CoreMainMenuMorePageModule),
},
...routes.children,
diff --git a/src/core/features/mainmenu/pages/menu/menu.html b/src/core/features/mainmenu/pages/menu/menu.html
index c86ab2ea3..916230a83 100644
--- a/src/core/features/mainmenu/pages/menu/menu.html
+++ b/src/core/features/mainmenu/pages/menu/menu.html
@@ -9,7 +9,7 @@
{{ tab.badge }}
-
+
{{ 'core.more' | translate }}
diff --git a/src/core/features/mainmenu/pages/menu/menu.ts b/src/core/features/mainmenu/pages/menu/menu.ts
index 45dbddbe4..d0298183f 100644
--- a/src/core/features/mainmenu/pages/menu/menu.ts
+++ b/src/core/features/mainmenu/pages/menu/menu.ts
@@ -21,7 +21,7 @@ import { CoreApp } from '@services/app';
import { CoreSites } from '@services/sites';
import { CoreTextUtils } from '@services/utils/text';
import { CoreEvents, CoreEventObserver } from '@singletons/events';
-import { CoreMainMenu } from '../../services/mainmenu';
+import { CoreMainMenu, CoreMainMenuProvider } from '../../services/mainmenu';
import { CoreMainMenuDelegate, CoreMainMenuHandlerToDisplay } from '../../services/mainmenu-delegate';
import { CoreDomUtils } from '@services/utils/dom';
import { Translate } from '@singletons';
@@ -43,6 +43,7 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
showTabs = false;
tabsPlacement = 'bottom';
hidden = false;
+ morePageName = CoreMainMenuProvider.MORE_PAGE_NAME;
protected subscription?: Subscription;
protected redirectObs?: CoreEventObserver;
@@ -152,7 +153,7 @@ export class CoreMainMenuPage implements OnInit, OnDestroy {
if (this.loaded && this.mainTabs && !this.mainTabs.getSelected()) {
// Select the first tab.
setTimeout(() => {
- this.mainTabs!.select(this.tabs[0]?.page || 'more');
+ this.mainTabs!.select(this.tabs[0]?.page || this.morePageName);
});
}
}
diff --git a/src/core/features/mainmenu/services/mainmenu.ts b/src/core/features/mainmenu/services/mainmenu.ts
index ac344f718..dc897890b 100644
--- a/src/core/features/mainmenu/services/mainmenu.ts
+++ b/src/core/features/mainmenu/services/mainmenu.ts
@@ -29,6 +29,7 @@ export class CoreMainMenuProvider {
static readonly NUM_MAIN_HANDLERS = 4;
static readonly ITEM_MIN_WIDTH = 72; // Min with of every item, based on 5 items on a 360 pixel wide screen.
+ static readonly MORE_PAGE_NAME = 'more';
protected tablet = false;
@@ -191,11 +192,24 @@ export class CoreMainMenuProvider {
return tablet ? 'side' : 'bottom';
}
+ /**
+ * Check if a certain page is the root of a main menu tab.
+ *
+ * @param page Name of the page.
+ * @return Promise resolved with boolean: whether it's the root of a main menu tab.
+ */
+ async isMainMenuTab(pageName: string): Promise {
+ if (pageName == CoreMainMenuProvider.MORE_PAGE_NAME) {
+ return true;
+ }
+
+ return this.isCurrentMainMenuHandler(pageName);
+ }
+
/**
* Check if a certain page is the root of a main menu handler currently displayed.
*
* @param page Name of the page.
- * @param pageParams Page params.
* @return Promise resolved with boolean: whether it's the root of a main menu handler.
*/
async isCurrentMainMenuHandler(pageName: string): Promise {
diff --git a/src/core/features/settings/pages/site/site.ts b/src/core/features/settings/pages/site/site.ts
index 79efc59bb..9d3402e4b 100644
--- a/src/core/features/settings/pages/site/site.ts
+++ b/src/core/features/settings/pages/site/site.ts
@@ -26,7 +26,7 @@ import { CoreSettingsHelper, CoreSiteSpaceUsage } from '../../services/settings-
import { CoreApp } from '@services/app';
import { CoreSiteInfo } from '@classes/site';
import { Translate } from '@singletons';
-import { CoreNavHelper } from '@services/nav-helper';
+import { CoreNavigator } from '@services/navigator';
/**
* Page that displays the list of site settings pages.
@@ -183,7 +183,7 @@ export class CoreSitePreferencesPage implements OnInit, OnDestroy {
openHandler(page: string, params?: Params): void {
this.selectedPage = page;
// this.splitviewCtrl.push(page, params);
- CoreNavHelper.instance.goInCurrentMainMenuTab(page, params);
+ CoreNavigator.instance.navigateToSitePath(page, { params });
}
/**
diff --git a/src/core/services/navigator.ts b/src/core/services/navigator.ts
index 7c03690fc..a74d4f9e1 100644
--- a/src/core/services/navigator.ts
+++ b/src/core/services/navigator.ts
@@ -203,6 +203,7 @@ export class CoreNavigatorService {
* If the path belongs to a visible tab, that tab will be selected.
* If it doesn't, the current tab or the default tab will be used instead.
*
+ * @param path Main menu path.
* @param options Navigation options.
* @return Whether navigation suceeded.
*/
@@ -213,22 +214,21 @@ export class CoreNavigatorService {
path = path.replace(/^(\.|\/main)?\//, '');
- // Open the path within the corresponding main tab.
const pathRoot = /^[^/]+/.exec(path)?.[0] ?? '';
- const isCurrentMainMenuHandler = await CoreUtils.instance.ignoreErrors(
- CoreMainMenu.instance.isCurrentMainMenuHandler(pathRoot),
+ const currentMainMenuTab = this.getCurrentMainMenuTab();
+ const isMainMenuTab = await CoreUtils.instance.ignoreErrors(
+ CoreMainMenu.instance.isMainMenuTab(pathRoot),
false,
);
- if (isCurrentMainMenuHandler) {
- return this.navigate(`/main/${path}`, options);
+ // Open the path within the current main tab.
+ if (currentMainMenuTab && (!isMainMenuTab || pathRoot !== currentMainMenuTab)) {
+ return this.navigate(`/main/${currentMainMenuTab}/${path}`, options);
}
- // Open the path within the current main tab.
- const currentMainMenuTab = this.getCurrentMainMenuTab();
-
- if (currentMainMenuTab) {
- return this.navigate(`/main/${currentMainMenuTab}/${path}`, options);
+ // Open the path within the corresponding main tab.
+ if (isMainMenuTab) {
+ return this.navigate(`/main/${path}`, options);
}
// Open the path within the default main tab.
diff --git a/src/core/services/tests/navigator.test.ts b/src/core/services/tests/navigator.test.ts
index 0d80c2270..6a68f7055 100644
--- a/src/core/services/tests/navigator.test.ts
+++ b/src/core/services/tests/navigator.test.ts
@@ -44,7 +44,7 @@ describe('CoreNavigator', () => {
mockSingleton(CoreUtils, new CoreUtilsProvider(mock()));
mockSingleton(CoreUrlUtils, new CoreUrlUtilsProvider());
mockSingleton(CoreSites, { getCurrentSiteId: () => 42, isLoggedIn: () => true });
- mockSingleton(CoreMainMenu, { isCurrentMainMenuHandler: path => Promise.resolve(currentMainMenuHandlers.includes(path)) });
+ mockSingleton(CoreMainMenu, { isMainMenuTab: path => Promise.resolve(currentMainMenuHandlers.includes(path)) });
});
it('matches against current path', () => {