commit
7343267fd0
|
@ -335,15 +335,15 @@ export class CoreLoginHelperProvider {
|
|||
*/
|
||||
getSitePolicy(siteId?: string): Promise<string> {
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
// Check if it's stored in the site config.
|
||||
const sitePolicy = site.getStoredConfig('sitepolicy');
|
||||
if (typeof sitePolicy != 'undefined') {
|
||||
// Try to get the latest config, maybe the site policy was just added or has changed.
|
||||
return site.getConfig('sitepolicy', true).then((sitePolicy) => {
|
||||
return sitePolicy ? sitePolicy : Promise.reject(null);
|
||||
}
|
||||
|
||||
// Not in the config, try to get it using auth_email_get_signup_settings.
|
||||
return this.wsProvider.callAjax('auth_email_get_signup_settings', {}, { siteUrl: site.getURL() }).then((settings) => {
|
||||
return settings.sitepolicy ? settings.sitepolicy : Promise.reject(null);
|
||||
}, () => {
|
||||
// Cannot get config, try to get the site policy using auth_email_get_signup_settings.
|
||||
return this.wsProvider.callAjax('auth_email_get_signup_settings', {}, { siteUrl: site.getURL() })
|
||||
.then((settings) => {
|
||||
return settings.sitepolicy ? settings.sitepolicy : Promise.reject(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import { CoreAppProvider } from '../app';
|
|||
import { CoreConfigProvider } from '../config';
|
||||
import { CoreUrlUtilsProvider } from './url';
|
||||
import { CoreConstants } from '@core/constants';
|
||||
import { Md5 } from 'ts-md5/dist/md5';
|
||||
|
||||
/*
|
||||
* "Utils" service with helper functions for UI, DOM elements and HTML code.
|
||||
|
@ -41,6 +42,7 @@ export class CoreDomUtilsProvider {
|
|||
protected instances: {[id: string]: any} = {}; // Store component/directive instances by id.
|
||||
protected lastInstanceId = 0;
|
||||
protected debugDisplay = false; // Whether to display debug messages. Store it in a variable to make it synchronous.
|
||||
protected displayedAlerts = {}; // To prevent duplicated alerts.
|
||||
|
||||
constructor(private translate: TranslateService, private loadingCtrl: LoadingController, private toastCtrl: ToastController,
|
||||
private alertCtrl: AlertController, private textUtils: CoreTextUtilsProvider, private appProvider: CoreAppProvider,
|
||||
|
@ -898,6 +900,12 @@ export class CoreDomUtilsProvider {
|
|||
}
|
||||
|
||||
return promise.then((message) => {
|
||||
const alertId = <string> Md5.hashAsciiStr((title || '') + '#' + (message || ''));
|
||||
|
||||
if (this.displayedAlerts[alertId]) {
|
||||
// There's already an alert with the same message and title. Return it.
|
||||
return this.displayedAlerts[alertId];
|
||||
}
|
||||
|
||||
const alert = this.alertCtrl.create({
|
||||
title: title,
|
||||
|
@ -913,6 +921,13 @@ export class CoreDomUtilsProvider {
|
|||
}
|
||||
});
|
||||
|
||||
// Store the alert and remove it when dismissed.
|
||||
this.displayedAlerts[alertId] = alert;
|
||||
|
||||
alert.onDidDismiss(() => {
|
||||
delete this.displayedAlerts[alertId];
|
||||
});
|
||||
|
||||
if (autocloseTime > 0) {
|
||||
setTimeout(() => {
|
||||
alert.dismiss();
|
||||
|
|
Loading…
Reference in New Issue