MOBILE-4245 Site: Remove load staging sites from site page

main
Alfonso Salces 2023-02-23 11:50:05 +01:00
parent 856a8a4957
commit 7a78bb9375
18 changed files with 129 additions and 139 deletions

View File

@ -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 {

View File

@ -290,14 +290,18 @@ export class CoreSite {
*
* @returns Site name.
*/
getSiteName(): string {
async getSiteName(): Promise<string> {
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 '';

View File

@ -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<void> {
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<void> {
const site = CoreSites.getRequiredCurrentSite();
this.siteName = await site.getSiteName() || '';
}
/**

View File

@ -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;

View File

@ -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<void> {
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);

View File

@ -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);

View File

@ -20,7 +20,7 @@
<div class="ion-text-center ion-padding ion-margin-bottom core-login-site-logo" [class.hidden]="hasSites || enteredSiteUrl">
<img src="assets/img/login_logo.png" class="avatar-full login-logo" role="presentation" alt="">
</div>
<form [formGroup]="siteForm" (ngSubmit)="connect($event, siteForm.value.siteUrl)" *ngIf="!fixedSites" #siteFormEl>
<form [formGroup]="siteForm" (ngSubmit)="connect($event, siteForm.value.siteUrl)" *ngIf="!fixedSites && siteForm" #siteFormEl>
<!-- Form to input the site URL if there are no fixed sites. -->
<ng-container *ngIf=" siteSelector=='url'">
<ion-item>
@ -101,7 +101,8 @@
</ng-container>
<ng-container *ngIf="showScanQR && !hasSites && !enteredSiteUrl">
<div class="ion-text-center ion-padding ion-margin-top core-login-site-qrcode-separator">{{ 'core.login.or' | translate }}</div>
<div class="ion-text-center ion-padding ion-margin-top core-login-site-qrcode-separator">{{ 'core.login.or' | translate }}
</div>
<ion-button expand="block" fill="outline" class="ion-margin core-login-site-qrcode" (click)="showInstructionsAndScanQR()"
aria-haspopup="dialog">
<ion-icon slot="start" name="fas-qrcode" aria-hidden="true"></ion-icon>
@ -119,7 +120,7 @@
<!-- Template site selector. -->
<ng-template #sitelisting let-site="site">
<ion-item button (click)="connect($event, site.url, site)" [attr.aria-label]="site.name" detail="true">
<ion-item button (click)="connect($event, site.url, site)" [ngClass]="site.className" [attr.aria-label]="site.name" detail="true">
<ion-thumbnail *ngIf="siteFinderSettings.displayimage" slot="start">
<img [src]="site.imageurl" *ngIf="site.imageurl" onError="this.src='assets/icon/icon.png'" alt="" role="presentation">
<img src="assets/icon/icon.png" *ngIf="!site.imageurl" class="core-login-default-icon" alt="" role="presentation">

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
import { Component, OnInit, ViewChild, ElementRef, OnDestroy } from '@angular/core';
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import { FormBuilder, FormGroup, ValidatorFn, AbstractControl, ValidationErrors } from '@angular/forms';
import { CoreApp } from '@services/app';
@ -46,7 +46,6 @@ import { CoreUserSupportConfig } from '@features/user/classes/support/support-co
import { CoreUserGuestSupportConfig } from '@features/user/classes/support/guest-support-config';
import { CoreLoginError } from '@classes/errors/loginerror';
import { CorePlatform } from '@services/platform';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
/**
* Site (url) chooser when adding a new site.
@ -56,7 +55,7 @@ import { CoreEventObserver, CoreEvents } from '@singletons/events';
templateUrl: 'site.html',
styleUrls: ['site.scss', '../../login.scss'],
})
export class CoreLoginSitePage implements OnInit, OnDestroy {
export class CoreLoginSitePage implements OnInit {
@ViewChild('siteFormEl') formElement?: ElementRef;
@ -73,10 +72,13 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
showScanQR!: boolean;
enteredSiteUrl?: CoreLoginSiteInfoExtended;
siteFinderSettings!: CoreLoginSiteFinderSettings;
stagingSitesChangeListener: CoreEventObserver;
constructor(protected formBuilder: FormBuilder) {
constructor(protected formBuilder: FormBuilder) {}
/**
* Initialize the component.
*/
async ngOnInit(): Promise<void> {
let url = '';
this.siteSelector = CoreConstants.CONFIG.multisitesdisplay;
@ -92,8 +94,10 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
};
// Load fixed sites if they're set.
if (CoreConstants.CONFIG.sites.length) {
url = this.initSiteSelector();
const sites = await CoreLoginHelper.getAvailableSites();
if (sites.length) {
url = await this.initSiteSelector();
} else if (CoreConstants.CONFIG.enableonboarding && !CorePlatform.isIOS()) {
this.initOnboarding();
}
@ -123,35 +127,7 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
this.loadingSites = false;
}, 1000);
this.stagingSitesChangeListener = CoreEvents.on(
CoreEvents.STAGING_SITES_CHANGE,
async ({ enabled }: { enabled: boolean }) => {
if (enabled) {
await this.loadStagingSites();
return;
}
if (CoreLoginHelper.hasSeveralFixedSites()) {
this.siteForm = this.formBuilder.group({
siteUrl: [this.initSiteSelector(), this.moodleUrlValidator()],
});
return;
}
this.filteredSites = undefined;
this.fixedSites = undefined;
},
);
}
/**
* Initialize the component.
*/
async ngOnInit(): Promise<void> {
this.showKeyboard = !!CoreNavigator.getRouteBooleanParam('showKeyboard');
await this.loadStagingSites();
}
/**
@ -159,8 +135,9 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
*
* @returns URL of the first site.
*/
protected initSiteSelector(): string {
this.fixedSites = this.extendCoreLoginSiteInfo(<CoreLoginSiteInfoExtended[]> CoreConstants.CONFIG.sites);
protected async initSiteSelector(): Promise<string> {
const availableSites = await CoreLoginHelper.getAvailableSites();
this.fixedSites = this.extendCoreLoginSiteInfo(<CoreLoginSiteInfoExtended[]> availableSites);
this.siteSelector = 'list'; // In case it's not defined
// Do not show images if none are set.
@ -173,35 +150,6 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
return this.fixedSites[0].url;
}
/**
* Load staging sites list if they are enabled.
*/
protected async loadStagingSites(): Promise<void> {
const stagingSites = await CoreLoginHelper.getStagingSites();
if (!stagingSites.length) {
return;
}
const sites = this.extendCoreLoginSiteInfo(<CoreLoginSiteInfoExtended[]> stagingSites);
this.siteSelector = 'list';
if (!this.fixedSites) {
this.fixedSites = [];
}
for (const site of sites) {
if (this.fixedSites.some(item => item.url === site.url)) {
continue;
}
this.fixedSites.push(site);
}
this.siteFinderSettings.displayimage = false;
this.filteredSites = this.fixedSites;
}
/**
* Initialize and show onboarding if needed.
*
@ -664,13 +612,6 @@ export class CoreLoginSitePage implements OnInit, OnDestroy {
CoreNavigator.navigate('/settings');
}
/**
* @inheritdoc
*/
ngOnDestroy(): void {
this.stagingSitesChangeListener.off();
}
}
/**

View File

@ -380,25 +380,23 @@ export class CoreLoginHelperProvider {
* Get fixed site or sites.
*
* @returns Fixed site or list of fixed sites.
* @deprecated 4.2.0 use CoreConstants.CONFIG.sites instead.
* @deprecated since 4.2.0. Use CoreConstants.CONFIG.sites or getAvailableSites() instead.
*/
getFixedSites(): string | CoreLoginSiteInfo[] {
return CoreLoginHelper.isUniqueFixedSite() ? CoreConstants.CONFIG.sites[0].url : CoreConstants.CONFIG.sites;
const notStagingSites = CoreConstants.CONFIG.sites.filter(site => !site.staging);
return notStagingSites.length === 1 ? notStagingSites[0].url : notStagingSites;
}
/**
* Get staging sites.
* Get Available sites (includes staging sites if are enabled).
*
* @returns Staging sites.
* @returns Available sites.
*/
async getStagingSites(): Promise<CoreLoginSiteInfo[]> {
async getAvailableSites(): Promise<CoreLoginSiteInfo[]> {
const hasEnabledStagingSites = await CoreSettingsHelper.hasEnabledStagingSites();
if (!hasEnabledStagingSites) {
return [];
}
return CoreConstants.CONFIG.stagingsites;
return hasEnabledStagingSites ? CoreConstants.CONFIG.sites : CoreConstants.CONFIG.sites.filter(site => !site.staging);
}
/**
@ -457,7 +455,7 @@ export class CoreLoginHelperProvider {
return;
}
} else {
[path, params] = this.getAddSiteRouteInfo(showKeyboard);
[path, params] = await this.getAddSiteRouteInfo(showKeyboard);
}
await CoreNavigator.navigate(path, { params, reset: setRoot });
@ -469,10 +467,12 @@ export class CoreLoginHelperProvider {
* @param showKeyboard Whether to show keyboard in the new page. Only if no fixed URL set.
* @returns Path and params.
*/
getAddSiteRouteInfo(showKeyboard?: boolean): [string, Params] {
if (CoreLoginHelper.isUniqueFixedSite()) {
async getAddSiteRouteInfo(showKeyboard?: boolean): Promise<[string, Params]> {
const sites = await this.getAvailableSites();
if (sites.length === 1) {
// Fixed URL is set, go to credentials page.
return ['/login/credentials', { siteUrl: CoreConstants.CONFIG.sites[0].url }];
return ['/login/credentials', { siteUrl: sites[0].url }];
}
return ['/login/site', { showKeyboard }];
@ -534,8 +534,10 @@ export class CoreLoginHelperProvider {
* @returns Whether there are several fixed URLs.
* @deprecated 4.2.0 Use CoreConstants.CONFIG.sites.length > 1 instead.
*/
hasSeveralFixedSites(): boolean {
return CoreConstants.CONFIG.sites.length > 1;
async hasSeveralFixedSites(): Promise<boolean> {
const sites = await this.getAvailableSites();
return sites.length > 1;
}
/**
@ -571,10 +573,10 @@ export class CoreLoginHelperProvider {
* Check if the app is configured to use a fixed URL (only 1).
*
* @returns Whether there is 1 fixed URL.
* @deprecated 4.2.0 Use isUniqueFixedSite instead.
* @deprecated 4.2.0 Use isSingleFixedSite instead.
*/
isFixedUrlSet(): boolean {
return this.isUniqueFixedSite();
return CoreConstants.CONFIG.sites.filter(site => !site.staging).length === 1;
}
/**
@ -582,8 +584,10 @@ export class CoreLoginHelperProvider {
*
* @returns Whether there is 1 fixed URL.
*/
isUniqueFixedSite(): boolean {
return CoreConstants.CONFIG.sites.length === 1;
async isSingleFixedSite(): Promise<boolean> {
const sites = await this.getAvailableSites();
return sites.length === 1;
}
/**
@ -626,8 +630,10 @@ export class CoreLoginHelperProvider {
* @returns Promise resolved with boolean: whether is one of the fixed sites.
*/
async isSiteUrlAllowed(siteUrl: string, checkSiteFinder = true): Promise<boolean> {
if (CoreConstants.CONFIG.sites.length) {
return CoreConstants.CONFIG.sites.some((site) => CoreUrl.sameDomainAndPath(siteUrl, site.url));
const sites = await this.getAvailableSites();
if (sites.length) {
return sites.some((site) => CoreUrl.sameDomainAndPath(siteUrl, site.url));
} else if (CoreConstants.CONFIG.multisitesdisplay == 'sitefinder' && CoreConstants.CONFIG.onlyallowlistedsites &&
checkSiteFinder) {
// Call the sites finder to validate the site.
@ -1318,12 +1324,14 @@ export class CoreLoginHelperProvider {
* @param qrCodeType QR Code type from public config, assuming enabled if undefined.
* @returns Whether the QR reader should be displayed in credentials screen.
*/
displayQRInCredentialsScreen(qrCodeType = CoreSiteQRCodeType.QR_CODE_LOGIN): boolean {
async displayQRInCredentialsScreen(qrCodeType = CoreSiteQRCodeType.QR_CODE_LOGIN): Promise<boolean> {
if (!CoreUtils.canScanQR()) {
return false;
}
if ((CoreConstants.CONFIG.displayqroncredentialscreen === undefined && CoreLoginHelper.isUniqueFixedSite()) ||
const isSingleFixedSite = await this.isSingleFixedSite();
if ((CoreConstants.CONFIG.displayqroncredentialscreen === undefined && isSingleFixedSite) ||
(CoreConstants.CONFIG.displayqroncredentialscreen !== undefined &&
!!CoreConstants.CONFIG.displayqroncredentialscreen)) {

View File

@ -65,7 +65,7 @@ export class CoreMainMenuUserMenuComponent implements OnInit, OnDestroy {
const currentSite = CoreSites.getRequiredCurrentSite();
this.siteId = currentSite.getId();
this.siteInfo = currentSite.getInfo();
this.siteName = currentSite.getSiteName();
this.siteName = await currentSite.getSiteName();
this.siteUrl = currentSite.getURL();
this.displaySwitchAccount = !currentSite.isFeatureDisabled('NoDelegate_SwitchAccount');
this.displayContactSupport = new CoreUserAuthenticatedSupportConfig(currentSite).canContactSupport();

View File

@ -45,18 +45,18 @@ export class CoreMainMenuHomePage implements OnInit {
/**
* @inheritdoc
*/
ngOnInit(): void {
async ngOnInit(): Promise<void> {
this.deepLinkManager = new CoreMainMenuDeepLinkManager();
this.loadSiteName();
await this.loadSiteName();
this.subscription = CoreMainMenuHomeDelegate.getHandlersObservable().subscribe((handlers) => {
handlers && this.initHandlers(handlers);
});
// Refresh the enabled flags if site is updated.
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, () => {
this.loadSiteName();
this.updateSiteObserver = CoreEvents.on(CoreEvents.SITE_UPDATED, async () => {
await this.loadSiteName();
}, CoreSites.getCurrentSiteId());
}
@ -99,8 +99,9 @@ export class CoreMainMenuHomePage implements OnInit {
/**
* Load the site name.
*/
protected loadSiteName(): void {
this.siteName = CoreSites.getRequiredCurrentSite().getSiteName() || '';
protected async loadSiteName(): Promise<void> {
const site = CoreSites.getRequiredCurrentSite();
this.siteName = await site.getSiteName() || '';
}
/**

View File

@ -34,7 +34,7 @@
<ion-label>
<h2>Enable staging sites ({{stagingSitesCount}})</h2>
</ion-label>
<ion-toggle [checked]="enableStagingSites" (ionChange)="setEnabledStagingSites($event.detail.checked)"></ion-toggle>
<ion-toggle [(ngModel)]="enableStagingSites" (ionChange)="setEnabledStagingSites($event.detail.checked)"></ion-toggle>
</ion-item>
<ng-container *ngIf="siteId">
<ion-item class="ion-text-wrap">

View File

@ -14,7 +14,7 @@
import { CoreConstants } from '@/core/constants';
import { Component, OnInit } from '@angular/core';
import { CoreLoginHelper, CoreLoginHelperProvider } from '@features/login/services/login-helper';
import { CoreLoginHelperProvider } from '@features/login/services/login-helper';
import { CoreSettingsHelper } from '@features/settings/services/settings-helper';
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
import { CoreUserTours } from '@features/usertours/services/user-tours';
@ -45,6 +45,7 @@ export class CoreSettingsDevPage implements OnInit {
userToursEnabled = true;
stagingSitesCount = 0;
enableStagingSites?: boolean;
listenStagingSitesChanges = false;
disabledFeatures: string[] = [];
@ -63,6 +64,7 @@ export class CoreSettingsDevPage implements OnInit {
if (this.stagingSitesCount) {
this.enableStagingSites = await CoreSettingsHelper.hasEnabledStagingSites();
this.listenStagingSitesChanges = true;
}
if (!this.siteId) {
@ -168,7 +170,19 @@ export class CoreSettingsDevPage implements OnInit {
}
async setEnabledStagingSites(enabled: boolean): Promise<void> {
await CoreSettingsHelper.setEnabledStagingSites(enabled);
if (!this.listenStagingSitesChanges) {
this.listenStagingSitesChanges = true;
return;
}
try {
await CoreSettingsHelper.setEnabledStagingSites(enabled);
} catch (error) {
this.enableStagingSites = !enabled;
this.listenStagingSitesChanges = false;
CoreDomUtils.showErrorModal(error);
}
}
}

View File

@ -168,10 +168,6 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
}
const currentSite = sitesProvider.getCurrentSite();
const firstUrl = CoreLoginHelper.isUniqueFixedSite() && CoreConstants.CONFIG.sites[0].url;
this.deviceInfo.siteUrl = currentSite?.getURL() || firstUrl || undefined;
this.deviceInfo.isPrefixedUrl = !!CoreConstants.CONFIG.sites.length;
this.deviceInfo.siteId = currentSite?.getId();
this.deviceInfo.siteVersion = currentSite?.getInfo()?.release;
@ -190,12 +186,21 @@ export class CoreSettingsDeviceInfoPage implements OnDestroy {
* Async part of the constructor.
*/
protected async asyncInit(): Promise<void> {
const sitesProvider = CoreSites.instance;
const fileProvider = CoreFile.instance;
const lang = await CoreLang.getCurrentLanguage();
this.deviceInfo.currentLanguage = lang;
this.currentLangName = CoreConstants.CONFIG.languages[lang];
const currentSite = sitesProvider.getCurrentSite();
const isSingleFixedSite = await CoreLoginHelper.isSingleFixedSite();
const sites = await CoreLoginHelper.getAvailableSites();
const firstUrl = isSingleFixedSite && sites[0].url;
this.deviceInfo.siteUrl = currentSite?.getURL() || firstUrl || undefined;
this.deviceInfo.isPrefixedUrl = !!sites.length;
if (fileProvider.isAvailable()) {
const basepath = await fileProvider.getBasePath();
this.deviceInfo.fileSystemRoot = basepath;

View File

@ -66,7 +66,7 @@ export class CoreSettingsSpaceUsagePage implements OnInit, OnDestroy {
const site = await CoreSites.getSite(siteId);
const siteInfo = site.getInfo();
siteEntry.siteName = site.getSiteName();
siteEntry.siteName = await site.getSiteName();
if (siteInfo) {
siteEntry.siteUrl = siteInfo.siteurl;

View File

@ -80,7 +80,7 @@ export class CoreSettingsSynchronizationPage implements OnInit, OnDestroy {
const siteInfo = site.getInfo();
siteEntry.siteName = site.getSiteName();
siteEntry.siteName = await site.getSiteName();
if (siteInfo) {
siteEntry.siteUrl = siteInfo.siteurl;

View File

@ -495,10 +495,15 @@ export class CoreSettingsHelperProvider {
* @param enabled Enabled or disabled staging sites.
*/
async setEnabledStagingSites(enabled: boolean): Promise<void> {
try {
await CoreConfig.set('stagingSites', enabled ? 1 : 0);
const reloadApp = !CoreSites.isLoggedIn();
if (reloadApp) {
await CoreDomUtils.showConfirm('Are you sure that you want to enable/disable staging sites?');
} catch {
}
await CoreConfig.set('stagingSites', enabled ? 1 : 0);
if (!reloadApp) {
return;
}

View File

@ -109,7 +109,9 @@ export class CoreUpdateManagerProvider {
* @returns Promise resolved when done.
*/
protected async checkCurrentSiteAllowed(): Promise<void> {
if (!CoreConstants.CONFIG.sites.length) {
const sites = await CoreLoginHelper.getAvailableSites();
if (!sites.length) {
return;
}