From 8eedb2afaca98d9d7e70d7f7fdfc20cedd1d23d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Ferrer=20Oca=C3=B1a?= Date: Tue, 6 Jul 2021 09:54:45 +0200 Subject: [PATCH] MOBILE-3320 core: Check WP Enabled --- src/core/services/sites.ts | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/services/sites.ts b/src/core/services/sites.ts index 2d14bda21..eb04d3fda 100644 --- a/src/core/services/sites.ts +++ b/src/core/services/sites.ts @@ -70,7 +70,6 @@ export class CoreSitesProvider { protected static readonly VALID_VERSION = 1; protected static readonly INVALID_VERSION = -1; - protected isWPApp = false; protected logger: CoreLogger; protected services = {}; protected sessionRestored = false; @@ -639,21 +638,28 @@ export class CoreSitesProvider { protected validateWorkplaceVersion(info: CoreSiteInfoResponse): number { const isWorkplace = !!info.functions && info.functions.some((func) => func.name == 'tool_program_get_user_programs'); - if (typeof this.isWPApp == 'undefined') { - this.isWPApp = false; // @todo - } + const isWPEnabled = this.isWorkplaceEnabled(); - if (!this.isWPApp && isWorkplace) { + if (!isWPEnabled && isWorkplace) { return CoreSitesProvider.WORKPLACE_APP; } - if (this.isWPApp && !isWorkplace) { + if (isWPEnabled && !isWorkplace) { return CoreSitesProvider.MOODLE_APP; } return CoreSitesProvider.VALID_VERSION; } + /** + * Check if the app is workplace enabled. + * + * @return If the app is workplace enabled. + */ + protected isWorkplaceEnabled(): boolean { + return false; + } + /** * Returns the release number from site release info. *