MOBILE-3496 login: Reset nav stack on login

main
Dani Palou 2021-03-29 13:24:07 +02:00
parent 4fb220661f
commit 9d0be0e7f8
2 changed files with 7 additions and 4 deletions

View File

@ -167,7 +167,10 @@ export class CoreNavigatorService {
* @return Whether navigation suceeded. * @return Whether navigation suceeded.
*/ */
async navigateToSiteHome(options: Omit<CoreNavigationOptions, 'reset'> & { siteId?: string } = {}): Promise<boolean> { async navigateToSiteHome(options: Omit<CoreNavigationOptions, 'reset'> & { siteId?: string } = {}): Promise<boolean> {
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( async navigateToSitePath(
path: string, path: string,
options: Omit<CoreNavigationOptions, 'reset'> & { siteId?: string } = {}, options: CoreNavigationOptions & { siteId?: string } = {},
): Promise<boolean> { ): Promise<boolean> {
const siteId = options.siteId ?? CoreSites.getCurrentSiteId(); const siteId = options.siteId ?? CoreSites.getCurrentSiteId();
const navigationOptions: CoreNavigationOptions = CoreObject.without(options, ['siteId']); const navigationOptions: CoreNavigationOptions = CoreObject.without(options, ['siteId']);
@ -391,7 +394,7 @@ export class CoreNavigatorService {
* @param options Navigation options. * @param options Navigation options.
* @return Whether navigation suceeded. * @return Whether navigation suceeded.
*/ */
protected async navigateToMainMenuPath(path: string, options: Omit<CoreNavigationOptions, 'reset'> = {}): Promise<boolean> { protected async navigateToMainMenuPath(path: string, options: CoreNavigationOptions = {}): Promise<boolean> {
// Due to DeepLinker, we need to remove the path from the URL before going to main menu. // 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. // IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL.
// @todo this.location.replaceState(''); // @todo this.location.replaceState('');

View File

@ -146,7 +146,7 @@ describe('CoreNavigator', () => {
const success = await navigator.navigateToSiteHome(); const success = await navigator.navigateToSiteHome();
expect(success).toBe(true); expect(success).toBe(true);
expect(navControllerMock.navigateForward).toHaveBeenCalledWith(['/main/home'], {}); expect(navControllerMock.navigateRoot).toHaveBeenCalledWith(['/main/home'], {});
}); });
it.todo('navigates to a different site'); it.todo('navigates to a different site');