From 9d0be0e7f8166b2b103fd474f8c892ba3f6d0376 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 29 Mar 2021 13:24:07 +0200 Subject: [PATCH] MOBILE-3496 login: Reset nav stack on login --- src/core/services/navigator.ts | 9 ++++++--- src/core/services/tests/navigator.test.ts | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/services/navigator.ts b/src/core/services/navigator.ts index 3df8f454b..aa808443a 100644 --- a/src/core/services/navigator.ts +++ b/src/core/services/navigator.ts @@ -167,7 +167,10 @@ export class CoreNavigatorService { * @return Whether navigation suceeded. */ async navigateToSiteHome(options: Omit & { siteId?: string } = {}): Promise { - return this.navigateToSitePath(DEFAULT_MAIN_MENU_TAB, options); + return this.navigateToSitePath(DEFAULT_MAIN_MENU_TAB, { + ...options, + reset: true, + }); } /** @@ -179,7 +182,7 @@ export class CoreNavigatorService { */ async navigateToSitePath( path: string, - options: Omit & { siteId?: string } = {}, + options: CoreNavigationOptions & { siteId?: string } = {}, ): Promise { const siteId = options.siteId ?? CoreSites.getCurrentSiteId(); const navigationOptions: CoreNavigationOptions = CoreObject.without(options, ['siteId']); @@ -391,7 +394,7 @@ export class CoreNavigatorService { * @param options Navigation options. * @return Whether navigation suceeded. */ - protected async navigateToMainMenuPath(path: string, options: Omit = {}): Promise { + protected async navigateToMainMenuPath(path: string, options: CoreNavigationOptions = {}): Promise { // Due to DeepLinker, we need to remove the path from the URL before going to main menu. // IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL. // @todo this.location.replaceState(''); diff --git a/src/core/services/tests/navigator.test.ts b/src/core/services/tests/navigator.test.ts index cc55954f9..5dffe7899 100644 --- a/src/core/services/tests/navigator.test.ts +++ b/src/core/services/tests/navigator.test.ts @@ -146,7 +146,7 @@ describe('CoreNavigator', () => { const success = await navigator.navigateToSiteHome(); expect(success).toBe(true); - expect(navControllerMock.navigateForward).toHaveBeenCalledWith(['/main/home'], {}); + expect(navControllerMock.navigateRoot).toHaveBeenCalledWith(['/main/home'], {}); }); it.todo('navigates to a different site');