From 62a04239cb9eb0dead1844d9c038f12ce778436b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 4 Mar 2024 10:24:52 +0100 Subject: [PATCH] MOBILE-2768 policy: Decouple policy service from initial bundle --- src/core/features/login/services/login-helper.ts | 9 +++++++-- .../policy/services/handlers/acceptances-link.ts | 3 ++- src/core/features/policy/services/handlers/user.ts | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/features/login/services/login-helper.ts b/src/core/features/login/services/login-helper.ts index a2aded067..98fb1c72c 100644 --- a/src/core/features/login/services/login-helper.ts +++ b/src/core/features/login/services/login-helper.ts @@ -57,7 +57,6 @@ import { IDENTITY_PROVIDER_FEATURE_NAME_PREFIX, } from '../constants'; import { LazyRoutesModule } from '@/app/app-routing.module'; -import { CorePolicy } from '@features/policy/services/policy'; /** * Helper provider that provides some common features regarding authentication. @@ -91,6 +90,8 @@ export class CoreLoginHelperProvider { * @deprecated since 4.4. Use CorePolicy.acceptMandatoryPolicies instead. */ async acceptSitePolicy(siteId?: string): Promise { + const { CorePolicy } = await import('@features/policy/services/policy'); + return CorePolicy.acceptMandatorySitePolicies(siteId); } @@ -285,6 +286,8 @@ export class CoreLoginHelperProvider { * @deprecated since 4.4. Use CorePolicy.getSitePoliciesURL instead. */ async getSitePolicy(siteId?: string): Promise { + const { CorePolicy } = await import('@features/policy/services/policy'); + return CorePolicy.getSitePoliciesURL(siteId); } @@ -1040,7 +1043,9 @@ export class CoreLoginHelperProvider { * @returns void * @deprecated since 4.4. Use CorePolicy.goToAcceptSitePolicies instead. */ - sitePolicyNotAgreed(siteId?: string): void { + async sitePolicyNotAgreed(siteId?: string): Promise { + const { CorePolicy } = await import('@features/policy/services/policy'); + return CorePolicy.goToAcceptSitePolicies(siteId); } diff --git a/src/core/features/policy/services/handlers/acceptances-link.ts b/src/core/features/policy/services/handlers/acceptances-link.ts index 047de6610..69485e126 100644 --- a/src/core/features/policy/services/handlers/acceptances-link.ts +++ b/src/core/features/policy/services/handlers/acceptances-link.ts @@ -18,7 +18,6 @@ import { CoreContentLinksHandlerBase } from '@features/contentlinks/classes/base import { CoreContentLinksAction } from '@features/contentlinks/services/contentlinks-delegate'; import { CoreNavigator } from '@services/navigator'; import { makeSingleton } from '@singletons'; -import { CorePolicy } from '../policy'; import { ACCEPTANCES_PAGE_NAME, POLICY_PAGE_NAME } from '@features/policy/constants'; import { CoreSites } from '@services/sites'; @@ -55,6 +54,8 @@ export class CorePolicyAcceptancesLinkHandlerService extends CoreContentLinksHan return false; } + const { CorePolicy } = await import('@features/policy/services/policy'); + return CorePolicy.isManageAcceptancesAvailable(siteId); } diff --git a/src/core/features/policy/services/handlers/user.ts b/src/core/features/policy/services/handlers/user.ts index 730f8401a..89159a9f4 100644 --- a/src/core/features/policy/services/handlers/user.ts +++ b/src/core/features/policy/services/handlers/user.ts @@ -19,7 +19,6 @@ import { CoreUserProfileHandler, CoreUserProfileHandlerData, } from '@features/user/services/user-delegate'; -import { CorePolicy } from '../policy'; import { CoreSites } from '@services/sites'; import { makeSingleton } from '@singletons'; import { CoreNavigator } from '@services/navigator'; @@ -40,6 +39,8 @@ export class CorePolicyUserHandlerService implements CoreUserProfileHandler { * @inheritdoc */ async isEnabled(): Promise { + const { CorePolicy } = await import('@features/policy/services/policy'); + const wsAvailable = await CorePolicy.isManageAcceptancesAvailable(); if (!wsAvailable) { return false;