diff --git a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts index 1266f98bf..9e9eb145e 100644 --- a/src/addons/storagemanager/pages/courses-storage/courses-storage.ts +++ b/src/addons/storagemanager/pages/courses-storage/courses-storage.ts @@ -261,7 +261,8 @@ export class AddonStorageManagerCoursesStoragePage implements OnInit, OnDestroy event.stopPropagation(); try { - const siteName = CoreSites.getRequiredCurrentSite().getSiteName(); + const site = CoreSites.getRequiredCurrentSite(); + const siteName = await site.getSiteName(); this.spaceUsage = await CoreSettingsHelper.deleteSiteStorage(siteName, this.siteId); } catch { diff --git a/src/core/classes/site.ts b/src/core/classes/site.ts index 88a110585..ac7b946e1 100644 --- a/src/core/classes/site.ts +++ b/src/core/classes/site.ts @@ -290,14 +290,18 @@ export class CoreSite { * * @returns Site name. */ - getSiteName(): string { + async getSiteName(): Promise { if (this.infos?.sitename) { return this.infos?.sitename; } // Fallback. - if (CoreLoginHelper.isUniqueFixedSite()) { - return CoreConstants.CONFIG.sites[0].name ; + const isSigleFixedSite = await CoreLoginHelper.isSingleFixedSite(); + + if (isSigleFixedSite) { + const sites = await CoreLoginHelper.getAvailableSites(); + + return sites[0].name; } return ''; diff --git a/src/core/features/courses/pages/my/my.ts b/src/core/features/courses/pages/my/my.ts index 99c212873..c9d956500 100644 --- a/src/core/features/courses/pages/my/my.ts +++ b/src/core/features/courses/pages/my/my.ts @@ -61,9 +61,9 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { constructor(protected loadsManager: PageLoadsManager) { // Refresh the enabled flags if site is updated. - this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => { + this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async () => { this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); - this.loadSiteName(); + await this.loadSiteName(); }, CoreSites.getCurrentSiteId()); @@ -78,13 +78,13 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { /** * @inheritdoc */ - ngOnInit(): void { + async ngOnInit(): Promise { this.downloadCoursesEnabled = !CoreCourses.isDownloadCoursesDisabledInSite(); const deepLinkManager = new CoreMainMenuDeepLinkManager(); deepLinkManager.treatLink(); - this.loadSiteName(); + await this.loadSiteName(); this.loadContent(true); } @@ -143,8 +143,9 @@ export class CoreCoursesMyPage implements OnInit, OnDestroy, AsyncDirective { /** * Load the site name. */ - protected loadSiteName(): void { - this.siteName = CoreSites.getRequiredCurrentSite().getSiteName() || ''; + protected async loadSiteName(): Promise { + const site = CoreSites.getRequiredCurrentSite(); + this.siteName = await site.getSiteName() || ''; } /** diff --git a/src/core/features/login/guards/has-sites.ts b/src/core/features/login/guards/has-sites.ts index 8a8a6ef20..a96745941 100644 --- a/src/core/features/login/guards/has-sites.ts +++ b/src/core/features/login/guards/has-sites.ts @@ -50,7 +50,7 @@ export class CoreLoginHasSitesGuard implements CanActivate, CanLoad { return true; } - const [path, params] = CoreLoginHelper.getAddSiteRouteInfo(); + const [path, params] = await CoreLoginHelper.getAddSiteRouteInfo(); const route = Router.parseUrl(path); route.queryParams = params; diff --git a/src/core/features/login/pages/credentials/credentials.ts b/src/core/features/login/pages/credentials/credentials.ts index 95a6ca7af..f5a0517c4 100644 --- a/src/core/features/login/pages/credentials/credentials.ts +++ b/src/core/features/login/pages/credentials/credentials.ts @@ -99,7 +99,9 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { this.treatSiteConfig(); } - if (CoreLoginHelper.isUniqueFixedSite() || !this.siteConfig) { + const isSingleFixedSite = await CoreLoginHelper.isSingleFixedSite(); + + if (isSingleFixedSite || !this.siteConfig) { // Fixed URL or not siteConfig retrieved from params, we need to check if it uses browser SSO login. this.checkSite(this.siteUrl, true); } else { @@ -196,12 +198,12 @@ export class CoreLoginCredentialsPage implements OnInit, OnDestroy { /** * Treat the site configuration (if it exists). */ - protected treatSiteConfig(): void { + protected async treatSiteConfig(): Promise { if (this.siteConfig) { this.siteName = this.siteConfig.sitename; this.logoUrl = CoreLoginHelper.getLogoUrl(this.siteConfig); this.authInstructions = this.siteConfig.authinstructions || Translate.instant('core.login.loginsteps'); - this.showScanQR = CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); + this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); const disabledFeatures = CoreLoginHelper.getDisabledFeatures(this.siteConfig); this.identityProviders = CoreLoginHelper.getValidIdentityProviders(this.siteConfig, disabledFeatures); diff --git a/src/core/features/login/pages/reconnect/reconnect.ts b/src/core/features/login/pages/reconnect/reconnect.ts index e37ba5702..65d696c93 100644 --- a/src/core/features/login/pages/reconnect/reconnect.ts +++ b/src/core/features/login/pages/reconnect/reconnect.ts @@ -31,7 +31,6 @@ import { CoreUserSupportConfig } from '@features/user/classes/support/support-co import { CoreUserAuthenticatedSupportConfig } from '@features/user/classes/support/authenticated-support-config'; import { Translate } from '@singletons'; import { SafeHtml } from '@angular/platform-browser'; -import { CoreConstants } from '@/core/constants'; /** * Page to enter the user password to reconnect to a site. @@ -109,14 +108,16 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { this.userFullName = site.infos.fullname; this.userAvatar = site.infos.userpictureurl; this.siteUrl = site.infos.siteurl; - this.siteName = site.getSiteName(); + this.siteName = await site.getSiteName(); this.supportConfig = new CoreUserAuthenticatedSupportConfig(site); // If login was OAuth we should only reach this page if the OAuth method ID has changed. this.isOAuth = site.isOAuth(); + const sites = await CoreLoginHelper.getAvailableSites(); + // Show logo instead of avatar if it's a fixed site. - this.showUserAvatar = !!this.userAvatar && !CoreConstants.CONFIG.sites.length; + this.showUserAvatar = !!this.userAvatar && !sites.length; this.checkSiteConfig(site); @@ -181,8 +182,12 @@ export class CoreLoginReconnectPage implements OnInit, OnDestroy { } this.isBrowserSSO = !this.isOAuth && CoreLoginHelper.isSSOLoginNeeded(this.siteConfig.typeoflogin); - this.showScanQR = CoreLoginHelper.displayQRInSiteScreen() || - CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); + + this.showScanQR = CoreLoginHelper.displayQRInSiteScreen(); + + if (!this.showScanQR) { + this.showScanQR = await CoreLoginHelper.displayQRInCredentialsScreen(this.siteConfig.tool_mobile_qrcodetype); + } await CoreSites.checkApplication(this.siteConfig); diff --git a/src/core/features/login/pages/site/site.html b/src/core/features/login/pages/site/site.html index 510e317c5..e2d50ea3d 100644 --- a/src/core/features/login/pages/site/site.html +++ b/src/core/features/login/pages/site/site.html @@ -20,7 +20,7 @@ -
+ @@ -101,7 +101,8 @@ - +