From 4b2b1c1e3e550c7795fc9a964b91cea18f8fda81 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Thu, 10 Jun 2021 14:55:09 +0200 Subject: [PATCH] MOBILE-3320 navigation: Review pending TODOs --- .../features/login/pages/credentials/credentials.ts | 1 - src/core/features/login/pages/reconnect/reconnect.ts | 12 ++++-------- src/core/features/mainmenu/pages/home/home.ts | 2 +- .../features/settings/services/settings-helper.ts | 1 - src/core/services/navigator.ts | 7 ------- src/core/services/sites.ts | 7 ++----- 6 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index c50e0ddc5..714b06934 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -261,7 +261,6 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { this.siteId = id; - // @todo test that this is working properly. await CoreNavigator.navigateToSiteHome({ params: { urlToOpen: this.urlToOpen } }); } catch (error) { CoreLoginHelper.treatUserTokenError(siteUrl, error, username, password); diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index 850f8f050..f48433217 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -23,7 +23,7 @@ import { CoreLoginHelper } from '@features/login/services/login-helper'; import { CoreSiteIdentityProvider, CoreSitePublicConfigResponse } from '@classes/site'; import { CoreEvents } from '@singletons/events'; import { CoreError } from '@classes/errors/error'; -import { CoreNavigationOptions, CoreNavigator, CoreRedirectPayload } from '@services/navigator'; +import { CoreNavigationOptions, CoreNavigator } from '@services/navigator'; import { CoreForms } from '@singletons/form'; /** @@ -208,13 +208,9 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { this.credForm.controls['password'].reset(); // Go to the site initial page. - // @todo test that this is working properly (could we use navigateToSitePath instead?). - await CoreNavigator.navigateToSiteHome({ - params: { - redirectPath: this.page, - redirectOptions: this.pageOptions, - } as CoreRedirectPayload, - }); + this.page + ? await CoreNavigator.navigateToSitePath(this.page, { params: this.pageOptions }) + : await CoreNavigator.navigateToSiteHome(); } catch (error) { CoreLoginHelper.treatUserTokenError(this.siteUrl, error, this.username, password); diff --git a/src/core/features/mainmenu/pages/home/home.ts b/src/core/features/mainmenu/pages/home/home.ts index d8c38e377..201215b47 100644 --- a/src/core/features/mainmenu/pages/home/home.ts +++ b/src/core/features/mainmenu/pages/home/home.ts @@ -59,7 +59,7 @@ export class CoreMainMenuHomePage implements OnInit { */ ngOnInit(): void { this.route.queryParams.subscribe((params: Partial & { urlToOpen?: string }) => { - this.urlToOpen = params.urlToOpen; + this.urlToOpen = params.urlToOpen ?? this.urlToOpen; if (params.redirectPath) { this.pendingRedirect = { diff --git a/src/core/features/settings/services/settings-helper.ts b/src/core/features/settings/services/settings-helper.ts index 7144656c3..713407274 100644 --- a/src/core/features/settings/services/settings-helper.ts +++ b/src/core/features/settings/services/settings-helper.ts @@ -455,7 +455,6 @@ export class CoreSettingsHelperProvider { */ canIUsePrefersColorScheme(): boolean { // The following check will check browser support but system may differ from that. - // @todo Detect SO support to watch media query. return window.matchMedia('(prefers-color-scheme)').media !== 'not all'; } diff --git a/src/core/services/navigator.ts b/src/core/services/navigator.ts index a70122071..b31e38079 100644 --- a/src/core/services/navigator.ts +++ b/src/core/services/navigator.ts @@ -199,8 +199,6 @@ export class CoreNavigatorService { const siteId = options.siteId ?? CoreSites.getCurrentSiteId(); const navigationOptions: CoreNavigationOptions = CoreObject.without(options, ['siteId']); - // @todo: When this function was in ContentLinksHelper, this code was inside NgZone. Check if it's needed. - // If the path doesn't belong to a site, call standard navigation. if (siteId === CoreConstants.NO_SITE_ID) { return this.navigate(path, { @@ -408,10 +406,6 @@ export class CoreNavigatorService { * @return Whether navigation suceeded. */ 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(''); - options = { preferCurrentTab: true, ...options, @@ -441,7 +435,6 @@ export class CoreNavigatorService { } // Open the path within the default main tab. - // @todo test that this is working as expected return this.navigate(`/main/${DEFAULT_MAIN_MENU_TAB}`, { ...options, params: { diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 0c1dd10ce..2d14bda21 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -752,7 +752,6 @@ export class CoreSitesProvider { }; const siteId = this.getCurrentSiteId(); - const downloadUrl = CoreApp.getAppStoreUrl(storesConfig); if (downloadUrl != null) { @@ -773,10 +772,8 @@ export class CoreSitesProvider { } if (siteId) { - // Logout if it's the currentSite. - if (siteId == this.getCurrentSiteId()) { - await this.logout(); - } + // Logout the currentSite. + await this.logout(); // Always expire the token. await this.setSiteLoggedOut(siteId, true);