MOBILE-2376 core: Decrease exceptions in console on start
parent
e1cb1ad7ec
commit
ce62a16460
|
@ -129,7 +129,7 @@ export class AddonMessagesMainMenuHandler implements CoreMainMenuHandler, CoreCr
|
|||
*/
|
||||
execute(siteId?: string): Promise<any> {
|
||||
if (this.sitesProvider.isCurrentSite(siteId)) {
|
||||
this.eventsProvider.trigger(AddonMessagesProvider.READ_CRON_EVENT, undefined, siteId);
|
||||
this.eventsProvider.trigger(AddonMessagesProvider.READ_CRON_EVENT, {}, siteId);
|
||||
}
|
||||
|
||||
if (this.appProvider.isDesktop() && this.localNotificationsProvider.isAvailable()) {
|
||||
|
|
|
@ -58,11 +58,12 @@ export class AddonMessagesSyncProvider extends CoreSyncBaseProvider {
|
|||
|
||||
/**
|
||||
* Get all messages pending to be sent in the site.
|
||||
* @param {boolean} [onlyDeviceOffline=false] True to only sync discussions that failed because device was offline,
|
||||
*
|
||||
* @param {string} [siteId] Site ID to sync. If not defined, sync all sites.
|
||||
* @param {boolean} [onlyDeviceOffline=false] True to only sync discussions that failed because device was offline.
|
||||
* @param {Promise<any>} Promise resolved if sync is successful, rejected if sync fails.
|
||||
*/
|
||||
protected syncAllDiscussionsFunc(onlyDeviceOffline: boolean = false, siteId?: string): Promise<any> {
|
||||
protected syncAllDiscussionsFunc(siteId?: string, onlyDeviceOffline: boolean = false): Promise<any> {
|
||||
const promise = onlyDeviceOffline ?
|
||||
this.messagesOffline.getAllDeviceOfflineMessages(siteId) :
|
||||
this.messagesOffline.getAllMessages(siteId);
|
||||
|
|
|
@ -264,6 +264,11 @@ export class AddonPushNotificationsProvider {
|
|||
return previous + parseInt(counter, 10);
|
||||
}, 0);
|
||||
|
||||
if (!this.appProvider.isDesktop() && !this.appProvider.isMobile()) {
|
||||
// Browser doesn't have an app badge, stop.
|
||||
return total;
|
||||
}
|
||||
|
||||
// Set the app badge.
|
||||
return this.badge.set(total).then(() => {
|
||||
return total;
|
||||
|
|
|
@ -133,24 +133,26 @@ export class AddonRemoteThemesProvider {
|
|||
* Get remote styles of a certain site.
|
||||
*
|
||||
* @param {string} [siteId] Site ID. If not defined, current site.
|
||||
* @return {Promise<{fileUrl: string, styles: string}>} Promise resolved with the styles and the URL of the CSS file.
|
||||
* @return {Promise<{fileUrl: string, styles: string}>} Promise resolved with the styles and the URL of the CSS file,
|
||||
* resolved with undefined if no styles to load.
|
||||
*/
|
||||
get(siteId?: string): Promise<{fileUrl: string, styles: string}> {
|
||||
siteId = siteId || this.sitesProvider.getCurrentSiteId();
|
||||
|
||||
let fileUrl;
|
||||
|
||||
return this.sitesProvider.getSite(siteId).then((site) => {
|
||||
const infos = site.getInfo();
|
||||
let promise,
|
||||
fileUrl;
|
||||
|
||||
if (infos && infos.mobilecssurl) {
|
||||
fileUrl = infos.mobilecssurl;
|
||||
|
||||
if (this.fileProvider.isAvailable()) {
|
||||
// The file system is available. Download the file and remove old CSS files if needed.
|
||||
return this.downloadFileAndRemoveOld(siteId, fileUrl);
|
||||
promise = this.downloadFileAndRemoveOld(siteId, fileUrl);
|
||||
} else {
|
||||
// Return the online URL.
|
||||
return fileUrl;
|
||||
promise = Promise.resolve(fileUrl);
|
||||
}
|
||||
} else {
|
||||
if (infos && infos.mobilecssurl === '') {
|
||||
|
@ -158,9 +160,10 @@ export class AddonRemoteThemesProvider {
|
|||
this.filepoolProvider.removeFilesByComponent(siteId, AddonRemoteThemesProvider.COMPONENT, 1);
|
||||
}
|
||||
|
||||
return Promise.reject(null);
|
||||
return;
|
||||
}
|
||||
}).then((url) => {
|
||||
|
||||
return promise.then((url) => {
|
||||
this.logger.debug('Loading styles from: ', url);
|
||||
|
||||
// Get the CSS content using HTTP because we will treat the styles before saving them in the file.
|
||||
|
@ -173,6 +176,7 @@ export class AddonRemoteThemesProvider {
|
|||
return Promise.reject(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,6 +212,11 @@ export class AddonRemoteThemesProvider {
|
|||
this.disableElement(this.stylesEls[siteId].element, disabled);
|
||||
|
||||
return this.get(siteId).then((data) => {
|
||||
if (typeof data == 'undefined') {
|
||||
// Nothing to load.
|
||||
return;
|
||||
}
|
||||
|
||||
const hash = <string> Md5.hashAsciiStr(data.styles);
|
||||
|
||||
// Update the styles only if they have changed.
|
||||
|
@ -271,6 +280,8 @@ export class AddonRemoteThemesProvider {
|
|||
preloadCurrentSite(): Promise<any> {
|
||||
return this.sitesProvider.getStoredCurrentSiteId().then((siteId) => {
|
||||
return this.addSite(siteId);
|
||||
}, () => {
|
||||
// No current site stored.
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -184,9 +184,9 @@ export class CoreCronDelegate {
|
|||
return this.setHandlerLastExecutionTime(name, Date.now()).then(() => {
|
||||
this.scheduleNextExecution(name);
|
||||
});
|
||||
}, () => {
|
||||
}, (error) => {
|
||||
// Handler call failed. Retry soon.
|
||||
this.logger.debug(`Execution of handler '${name}' failed.`);
|
||||
this.logger.error(`Execution of handler '${name}' failed.`, error);
|
||||
this.scheduleNextExecution(name, CoreCronDelegate.MIN_INTERVAL);
|
||||
|
||||
return Promise.reject(null);
|
||||
|
@ -440,7 +440,9 @@ export class CoreCronDelegate {
|
|||
|
||||
this.handlers[name].timeout = setTimeout(() => {
|
||||
delete this.handlers[name].timeout;
|
||||
this.checkAndExecuteHandler(name);
|
||||
this.checkAndExecuteHandler(name).catch(() => {
|
||||
// Ignore errors.
|
||||
});
|
||||
}, nextExecution);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -918,7 +918,9 @@ export class CoreFileProvider {
|
|||
* @return {Promise<any>} Promise resolved when done.
|
||||
*/
|
||||
clearTmpFolder(): Promise<any> {
|
||||
return this.removeDir(CoreFileProvider.TMPFOLDER);
|
||||
return this.removeDir(CoreFileProvider.TMPFOLDER).catch(() => {
|
||||
// Ignore errors because the folder might not exist.
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -975,6 +975,8 @@ export class CoreSitesProvider {
|
|||
this.logger.debug(`Restore session in site ${siteId}`);
|
||||
|
||||
return this.loadSite(siteId);
|
||||
}).catch(() => {
|
||||
// No current session.
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue