diff --git a/src/classes/site.ts b/src/classes/site.ts index d01a31ac2..dc0ebd97f 100644 --- a/src/classes/site.ts +++ b/src/classes/site.ts @@ -78,6 +78,12 @@ export interface CoreSiteWSPreSets { */ getEmergencyCacheUsingCacheKey?: boolean; + /** + * If true, the cache entry will be deleted if the WS call returns an exception. + * @type {boolean} + */ + deleteCacheIfWSError?: boolean; + /** * Whether it should only be 1 entry for this cache key (all entries with same key will be deleted). * @type {boolean} @@ -633,6 +639,15 @@ export class CoreSite { return Promise.reject(error); } + if (preSets.deleteCacheIfWSError && this.utils.isWebServiceError(error)) { + // Delete the cache entry and return the entry. Don't block the user with the delete. + this.deleteFromCache(method, data, preSets).catch(() => { + // Ignore errors. + }); + + return Promise.reject(error); + } + this.logger.debug(`WS call '${method}' failed. Trying to use the emergency cache.`); preSets.omitExpires = true; preSets.getFromCache = true; diff --git a/src/core/siteplugins/classes/course-option-handler.ts b/src/core/siteplugins/classes/course-option-handler.ts index c54f049a3..66b2c5c6f 100644 --- a/src/core/siteplugins/classes/course-option-handler.ts +++ b/src/core/siteplugins/classes/course-option-handler.ts @@ -25,7 +25,7 @@ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandl priority: number; constructor(name: string, protected title: string, protected plugin: any, protected handlerSchema: any, - protected bootstrapResult: any, protected sitePluginsProvider: CoreSitePluginsProvider) { + protected initResult: any, protected sitePluginsProvider: CoreSitePluginsProvider) { super(name); this.priority = handlerSchema.priority; @@ -42,7 +42,7 @@ export class CoreSitePluginsCourseOptionHandler extends CoreSitePluginsBaseHandl */ isEnabledForCourse(courseId: number, accessData: any, navOptions?: any, admOptions?: any): boolean | Promise { return this.sitePluginsProvider.isHandlerEnabledForCourse( - courseId, this.handlerSchema.restricttoenrolledcourses, this.bootstrapResult.restrict); + courseId, this.handlerSchema.restricttoenrolledcourses, this.initResult.restrict); } /** diff --git a/src/core/siteplugins/classes/main-menu-handler.ts b/src/core/siteplugins/classes/main-menu-handler.ts index 7be3245ac..d837d7525 100644 --- a/src/core/siteplugins/classes/main-menu-handler.ts +++ b/src/core/siteplugins/classes/main-menu-handler.ts @@ -22,7 +22,7 @@ export class CoreSitePluginsMainMenuHandler extends CoreSitePluginsBaseHandler i priority: number; constructor(name: string, protected title: string, protected plugin: any, protected handlerSchema: any, - protected bootstrapResult: any) { + protected initResult: any) { super(name); this.priority = handlerSchema.priority; @@ -43,7 +43,7 @@ export class CoreSitePluginsMainMenuHandler extends CoreSitePluginsBaseHandler i title: this.title, component: this.plugin.component, method: this.handlerSchema.method, - bootstrapResult: this.bootstrapResult + initResult: this.initResult } }; } diff --git a/src/core/siteplugins/classes/user-handler.ts b/src/core/siteplugins/classes/user-handler.ts index 0b003e56e..fb4851f61 100644 --- a/src/core/siteplugins/classes/user-handler.ts +++ b/src/core/siteplugins/classes/user-handler.ts @@ -38,7 +38,7 @@ export class CoreSitePluginsUserProfileHandler extends CoreSitePluginsBaseHandle type: string; constructor(name: string, protected title: string, protected plugin: any, protected handlerSchema: any, - protected bootstrapResult: any, protected sitePluginsProvider: CoreSitePluginsProvider) { + protected initResult: any, protected sitePluginsProvider: CoreSitePluginsProvider) { super(name); this.priority = handlerSchema.priority; @@ -59,14 +59,14 @@ export class CoreSitePluginsUserProfileHandler extends CoreSitePluginsBaseHandle isEnabledForUser(user: any, courseId: number, navOptions?: any, admOptions?: any): boolean | Promise { // First check if it's enabled for the user. const enabledForUser = this.sitePluginsProvider.isHandlerEnabledForUser(user.id, this.handlerSchema.restricttocurrentuser, - this.bootstrapResult.restrict); + this.initResult.restrict); if (!enabledForUser) { return false; } // Enabled for user, check if it's enabled for the course. return this.sitePluginsProvider.isHandlerEnabledForCourse( - courseId, this.handlerSchema.restricttoenrolledcourses, this.bootstrapResult.restrict); + courseId, this.handlerSchema.restricttoenrolledcourses, this.initResult.restrict); } /** @@ -92,7 +92,7 @@ export class CoreSitePluginsUserProfileHandler extends CoreSitePluginsBaseHandle courseid: courseId, userid: user.id }, - bootstrapResult: this.bootstrapResult + initResult: this.initResult }); } }; diff --git a/src/core/siteplugins/components/course-format/course-format.html b/src/core/siteplugins/components/course-format/course-format.html index b4dd6868b..cd6008506 100644 --- a/src/core/siteplugins/components/course-format/course-format.html +++ b/src/core/siteplugins/components/course-format/course-format.html @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/core/siteplugins/components/course-format/course-format.ts b/src/core/siteplugins/components/course-format/course-format.ts index 72a5972f4..964b9300f 100644 --- a/src/core/siteplugins/components/course-format/course-format.ts +++ b/src/core/siteplugins/components/course-format/course-format.ts @@ -33,7 +33,7 @@ export class CoreSitePluginsCourseFormatComponent implements OnInit { component: string; method: string; args: any; - bootstrapResult: any; + initResult: any; constructor(protected sitePluginsProvider: CoreSitePluginsProvider) { } @@ -50,7 +50,7 @@ export class CoreSitePluginsCourseFormatComponent implements OnInit { courseid: this.course.id, downloadenabled: this.downloadEnabled }; - this.bootstrapResult = handler.bootstrapResult; + this.initResult = handler.initResult; } } } diff --git a/src/core/siteplugins/components/course-option/course-option.html b/src/core/siteplugins/components/course-option/course-option.html index fcda25ccd..b2191c305 100644 --- a/src/core/siteplugins/components/course-option/course-option.html +++ b/src/core/siteplugins/components/course-option/course-option.html @@ -2,5 +2,5 @@ - + \ No newline at end of file diff --git a/src/core/siteplugins/components/course-option/course-option.ts b/src/core/siteplugins/components/course-option/course-option.ts index b14e67b76..27725faba 100644 --- a/src/core/siteplugins/components/course-option/course-option.ts +++ b/src/core/siteplugins/components/course-option/course-option.ts @@ -32,7 +32,7 @@ export class CoreSitePluginsCourseOptionComponent implements OnInit { component: string; method: string; args: any; - bootstrapResult: any; + initResult: any; constructor(protected sitePluginsProvider: CoreSitePluginsProvider) { } @@ -48,7 +48,7 @@ export class CoreSitePluginsCourseOptionComponent implements OnInit { this.args = { courseid: this.courseId, }; - this.bootstrapResult = handler.bootstrapResult; + this.initResult = handler.initResult; } } } diff --git a/src/core/siteplugins/components/module-index/module-index.html b/src/core/siteplugins/components/module-index/module-index.html index bee280179..6e09aa864 100644 --- a/src/core/siteplugins/components/module-index/module-index.html +++ b/src/core/siteplugins/components/module-index/module-index.html @@ -9,4 +9,4 @@ - + diff --git a/src/core/siteplugins/components/module-index/module-index.ts b/src/core/siteplugins/components/module-index/module-index.ts index c3cfb5e01..d1b77d2a6 100644 --- a/src/core/siteplugins/components/module-index/module-index.ts +++ b/src/core/siteplugins/components/module-index/module-index.ts @@ -37,7 +37,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C component: string; method: string; args: any; - bootstrapResult: any; + initResult: any; // Data for context menu. externalUrl: string; @@ -69,7 +69,7 @@ export class CoreSitePluginsModuleIndexComponent implements OnInit, OnDestroy, C courseid: this.courseId, cmid: this.module.id }; - this.bootstrapResult = handler.bootstrapResult; + this.initResult = handler.initResult; } // Get the data for the context menu. diff --git a/src/core/siteplugins/components/plugin-content/plugin-content.ts b/src/core/siteplugins/components/plugin-content/plugin-content.ts index 0e31421ea..60e01389a 100644 --- a/src/core/siteplugins/components/plugin-content/plugin-content.ts +++ b/src/core/siteplugins/components/plugin-content/plugin-content.ts @@ -28,7 +28,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit { @Input() component: string; @Input() method: string; @Input() args: any; - @Input() bootstrapResult: any; // Result of the bootstrap WS call of the handler. + @Input() initResult: any; // Result of the init WS call of the handler. @Output() onContentLoaded?: EventEmitter; // Emits an event when the content is loaded. @Output() onLoadingContent?: EventEmitter; // Emits an event when starts to load the content. @@ -65,7 +65,7 @@ export class CoreSitePluginsPluginContentComponent implements OnInit { this.content = result.templates.length ? result.templates[0].html : ''; // Load first template. this.javascript = result.javascript; this.otherData = result.otherdata; - this.jsData = this.sitePluginsProvider.createDataForJS(this.bootstrapResult, result); + this.jsData = this.sitePluginsProvider.createDataForJS(this.initResult, result); this.onContentLoaded.emit(refresh); }).catch((error) => { diff --git a/src/core/siteplugins/directives/call-ws-new-content.ts b/src/core/siteplugins/directives/call-ws-new-content.ts index 7f1346ef5..44f918f60 100644 --- a/src/core/siteplugins/directives/call-ws-new-content.ts +++ b/src/core/siteplugins/directives/call-ws-new-content.ts @@ -92,7 +92,7 @@ export class CoreSitePluginsCallWSNewContentDirective extends CoreSitePluginsCal component: this.component, method: this.method, args: args, - bootstrapResult: this.parentContent && this.parentContent.bootstrapResult + initResult: this.parentContent && this.parentContent.initResult }); } } diff --git a/src/core/siteplugins/directives/new-content.ts b/src/core/siteplugins/directives/new-content.ts index 6503ed5a2..3f7e5933d 100644 --- a/src/core/siteplugins/directives/new-content.ts +++ b/src/core/siteplugins/directives/new-content.ts @@ -89,7 +89,7 @@ export class CoreSitePluginsNewContentDirective implements OnInit { component: this.component, method: this.method, args: args, - bootstrapResult: this.parentContent && this.parentContent.bootstrapResult + initResult: this.parentContent && this.parentContent.initResult }); } }); diff --git a/src/core/siteplugins/pages/plugin-page/plugin-page.html b/src/core/siteplugins/pages/plugin-page/plugin-page.html index 33f22af85..22c2ebe07 100644 --- a/src/core/siteplugins/pages/plugin-page/plugin-page.html +++ b/src/core/siteplugins/pages/plugin-page/plugin-page.html @@ -11,5 +11,5 @@ - + diff --git a/src/core/siteplugins/pages/plugin-page/plugin-page.ts b/src/core/siteplugins/pages/plugin-page/plugin-page.ts index 38d516a47..0b02ad00a 100644 --- a/src/core/siteplugins/pages/plugin-page/plugin-page.ts +++ b/src/core/siteplugins/pages/plugin-page/plugin-page.ts @@ -32,14 +32,14 @@ export class CoreSitePluginsPluginPage { component: string; method: string; args: any; - bootstrapResult: any; + initResult: any; constructor(params: NavParams) { this.title = params.get('title'); this.component = params.get('component'); this.method = params.get('method'); this.args = params.get('args'); - this.bootstrapResult = params.get('bootstrapResult'); + this.initResult = params.get('initResult'); } /** diff --git a/src/core/siteplugins/providers/helper.ts b/src/core/siteplugins/providers/helper.ts index 95cffee2d..9d6fa24e5 100644 --- a/src/core/siteplugins/providers/helper.ts +++ b/src/core/siteplugins/providers/helper.ts @@ -89,19 +89,19 @@ export class CoreSitePluginsHelperProvider { } /** - * Bootstrap a handler if it has some bootstrap method. + * Execute a handler's init method if it has any. * * @param {any} plugin Data of the plugin. * @param {any} handlerSchema Data about the handler. * @return {Promise} Promise resolved when done. It returns the results of the getContent call and the data returned by - * the bootstrap JS (if any). + * the init JS (if any). */ - protected bootstrapHandler(plugin: any, handlerSchema: any): Promise { - if (!handlerSchema.bootstrap) { + protected executeHandlerInit(plugin: any, handlerSchema: any): Promise { + if (!handlerSchema.init) { return Promise.resolve({}); } - return this.executeMethodAndJS(plugin, handlerSchema.bootstrap); + return this.executeMethodAndJS(plugin, handlerSchema.init, true); } /** @@ -109,12 +109,16 @@ export class CoreSitePluginsHelperProvider { * * @param {any} plugin Data of the plugin. * @param {string} method The method to call. + * @param {boolean} [isInit] Whether it's the init method. * @return {Promise} Promise resolved when done. It returns the results of the getContent call and the data returned by * the JS (if any). */ - protected executeMethodAndJS(plugin: any, method: string): Promise { + protected executeMethodAndJS(plugin: any, method: string, isInit?: boolean): Promise { const siteId = this.sitesProvider.getCurrentSiteId(), - preSets = {getFromCache: false}; // Try to ignore cache. + preSets = { + getFromCache: false, // Try to ignore cache. + deleteCacheIfWSError: isInit // If the init WS call returns an exception we won't use cached data. + }; return this.sitePluginsProvider.getContent(plugin.component, method, {}, preSets).then((result) => { if (!result.javascript || this.sitesProvider.getCurrentSiteId() != siteId) { @@ -290,8 +294,8 @@ export class CoreSitePluginsHelperProvider { */ registerHandler(plugin: any, handlerName: string, handlerSchema: any): Promise { - // Wait for the bootstrap JS to be executed. - return this.bootstrapHandler(plugin, handlerSchema).then((result) => { + // Wait for the init JS to be executed. + return this.executeHandlerInit(plugin, handlerSchema).then((result) => { let promise; switch (handlerSchema.delegate) { @@ -331,12 +335,12 @@ export class CoreSitePluginsHelperProvider { plugin: plugin, handlerName: handlerName, handlerSchema: handlerSchema, - bootstrapResult: result + initResult: result }); } }); }).catch((err) => { - this.logger.error('Error executing bootstrap method', handlerSchema.bootstrap, err); + this.logger.error('Error executing init method', handlerSchema.init, err); }); } @@ -346,11 +350,11 @@ export class CoreSitePluginsHelperProvider { * @param {any} plugin Data of the plugin. * @param {string} handlerName Name of the handler in the plugin. * @param {any} handlerSchema Data about the handler. - * @param {any} bootstrapResult Result of the bootstrap WS call. + * @param {any} initResult Result of the init WS call. * @return {string} A string to identify the handler. */ - protected registerCourseFormatHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string { - this.logger.debug('Register site plugin in course format delegate:', plugin, handlerSchema, bootstrapResult); + protected registerCourseFormatHandler(plugin: any, handlerName: string, handlerSchema: any, initResult: any): string { + this.logger.debug('Register site plugin in course format delegate:', plugin, handlerSchema, initResult); // Create and register the handler. const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), @@ -366,10 +370,10 @@ export class CoreSitePluginsHelperProvider { * @param {any} plugin Data of the plugin. * @param {string} handlerName Name of the handler in the plugin. * @param {any} handlerSchema Data about the handler. - * @param {any} bootstrapResult Result of the bootstrap WS call. + * @param {any} initResult Result of the init WS call. * @return {string} A string to identify the handler. */ - protected registerCourseOptionHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string { + protected registerCourseOptionHandler(plugin: any, handlerName: string, handlerSchema: any, initResult: any): string { if (!handlerSchema.displaydata) { // Required data not provided, stop. this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema); @@ -377,14 +381,14 @@ export class CoreSitePluginsHelperProvider { return; } - this.logger.debug('Register site plugin in course option delegate:', plugin, handlerSchema, bootstrapResult); + this.logger.debug('Register site plugin in course option delegate:', plugin, handlerSchema, initResult); // Create and register the handler. const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title); this.courseOptionsDelegate.registerHandler(new CoreSitePluginsCourseOptionHandler(uniqueName, prefixedTitle, plugin, - handlerSchema, bootstrapResult, this.sitePluginsProvider)); + handlerSchema, initResult, this.sitePluginsProvider)); return uniqueName; } @@ -395,10 +399,10 @@ export class CoreSitePluginsHelperProvider { * @param {any} plugin Data of the plugin. * @param {string} handlerName Name of the handler in the plugin. * @param {any} handlerSchema Data about the handler. - * @param {any} bootstrapResult Result of the bootstrap WS call. + * @param {any} initResult Result of the init WS call. * @return {string} A string to identify the handler. */ - protected registerMainMenuHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string { + protected registerMainMenuHandler(plugin: any, handlerName: string, handlerSchema: any, initResult: any): string { if (!handlerSchema.displaydata) { // Required data not provided, stop. this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema); @@ -406,14 +410,14 @@ export class CoreSitePluginsHelperProvider { return; } - this.logger.debug('Register site plugin in main menu delegate:', plugin, handlerSchema, bootstrapResult); + this.logger.debug('Register site plugin in main menu delegate:', plugin, handlerSchema, initResult); // Create and register the handler. const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title); this.mainMenuDelegate.registerHandler( - new CoreSitePluginsMainMenuHandler(uniqueName, prefixedTitle, plugin, handlerSchema, bootstrapResult)); + new CoreSitePluginsMainMenuHandler(uniqueName, prefixedTitle, plugin, handlerSchema, initResult)); return uniqueName; } @@ -424,10 +428,10 @@ export class CoreSitePluginsHelperProvider { * @param {any} plugin Data of the plugin. * @param {string} handlerName Name of the handler in the plugin. * @param {any} handlerSchema Data about the handler. - * @param {any} bootstrapResult Result of the bootstrap WS call. + * @param {any} initResult Result of the init WS call. * @return {string} A string to identify the handler. */ - protected registerModuleHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string { + protected registerModuleHandler(plugin: any, handlerName: string, handlerSchema: any, initResult: any): string { if (!handlerSchema.displaydata) { // Required data not provided, stop. this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema); @@ -435,7 +439,7 @@ export class CoreSitePluginsHelperProvider { return; } - this.logger.debug('Register site plugin in module delegate:', plugin, handlerSchema, bootstrapResult); + this.logger.debug('Register site plugin in module delegate:', plugin, handlerSchema, initResult); // Create and register the handler. const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), @@ -458,10 +462,10 @@ export class CoreSitePluginsHelperProvider { * @param {any} plugin Data of the plugin. * @param {string} handlerName Name of the handler in the plugin. * @param {any} handlerSchema Data about the handler. - * @param {any} bootstrapResult Result of the bootstrap WS call. + * @param {any} initResult Result of the init WS call. * @return {string} A string to identify the handler. */ - protected registerUserProfileHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any): string { + protected registerUserProfileHandler(plugin: any, handlerName: string, handlerSchema: any, initResult: any): string { if (!handlerSchema.displaydata) { // Required data not provided, stop. this.logger.warn('Ignore site plugin because it doesn\'t provide displaydata', plugin, handlerSchema); @@ -469,14 +473,14 @@ export class CoreSitePluginsHelperProvider { return; } - this.logger.debug('Register site plugin in user profile delegate:', plugin, handlerSchema, bootstrapResult); + this.logger.debug('Register site plugin in user profile delegate:', plugin, handlerSchema, initResult); // Create and register the handler. const uniqueName = this.sitePluginsProvider.getHandlerUniqueName(plugin, handlerName), prefixedTitle = this.getPrefixedString(plugin.addon, handlerSchema.displaydata.title); this.userDelegate.registerHandler(new CoreSitePluginsUserProfileHandler(uniqueName, prefixedTitle, plugin, handlerSchema, - bootstrapResult, this.sitePluginsProvider)); + initResult, this.sitePluginsProvider)); return uniqueName; } @@ -487,10 +491,10 @@ export class CoreSitePluginsHelperProvider { * @param {any} plugin Data of the plugin. * @param {string} handlerName Name of the handler in the plugin. * @param {any} handlerSchema Data about the handler. - * @param {any} bootstrapResult Result of the bootstrap WS call. + * @param {any} initResult Result of the init WS call. * @return {string|Promise} A string (or a promise resolved with a string) to identify the handler. */ - protected registerUserProfileFieldHandler(plugin: any, handlerName: string, handlerSchema: any, bootstrapResult: any) + protected registerUserProfileFieldHandler(plugin: any, handlerName: string, handlerSchema: any, initResult: any) : string | Promise { if (!handlerSchema.method) { // Required data not provided, stop. @@ -499,7 +503,7 @@ export class CoreSitePluginsHelperProvider { return; } - this.logger.debug('Register site plugin in user profile field delegate:', plugin, handlerSchema, bootstrapResult); + this.logger.debug('Register site plugin in user profile field delegate:', plugin, handlerSchema, initResult); // Execute the main method and its JS. The template returned will be used in the profile field component. return this.executeMethodAndJS(plugin, handlerSchema.method).then((result) => { diff --git a/src/core/siteplugins/providers/siteplugins.ts b/src/core/siteplugins/providers/siteplugins.ts index dd3eb2ad5..bd7519cc9 100644 --- a/src/core/siteplugins/providers/siteplugins.ts +++ b/src/core/siteplugins/providers/siteplugins.ts @@ -47,10 +47,10 @@ export interface CoreSitePluginsHandler { handlerSchema: any; /** - * Result of the bootstrap WS call. + * Result of the init WS call. * @type {any} */ - bootstrapResult?: any; + initResult?: any; } /** @@ -137,23 +137,23 @@ export class CoreSitePluginsProvider { } /** - * Given the result of a bootstrap get_content and, optionally, the result of another get_content, + * Given the result of a init get_content and, optionally, the result of another get_content, * build an object with the data to pass to the JS of the get_content. * - * @param {any} bootstrapResult Result of the bootstrap WS call. + * @param {any} initResult Result of the init WS call. * @param {any} [contentResult] Result of the content WS call (if any). * @return {any} An object with the data to pass to the JS. */ - createDataForJS(bootstrapResult: any, contentResult?: any): any { - // First of all, add the data returned by the bootstrap JS (if any). - let data = this.utils.clone(bootstrapResult.jsResult || {}); + createDataForJS(initResult: any, contentResult?: any): any { + // First of all, add the data returned by the init JS (if any). + let data = this.utils.clone(initResult.jsResult || {}); if (typeof data == 'boolean') { data = {}; } - // Now add some data returned by the bootstrap WS call. - data.BOOTSTRAP_TEMPLATES = this.utils.objectToKeyValueMap(bootstrapResult.templates, 'id', 'html'); - data.BOOTSTRAP_OTHERDATA = bootstrapResult.otherdata; + // Now add some data returned by the init WS call. + data.INIT_TEMPLATES = this.utils.objectToKeyValueMap(initResult.templates, 'id', 'html'); + data.INIT_OTHERDATA = initResult.otherdata; if (contentResult) { // Now add the data returned by the content WS call. diff --git a/src/providers/utils/utils.ts b/src/providers/utils/utils.ts index 598415aa9..4fe7814fb 100644 --- a/src/providers/utils/utils.ts +++ b/src/providers/utils/utils.ts @@ -626,7 +626,11 @@ export class CoreUtilsProvider { * @return {boolean} Whether the error was returned by the WebService. */ isWebServiceError(error: any): boolean { - return typeof error.errorcode == 'undefined' && typeof error.warningcode == 'undefined'; + return typeof error.warningcode != 'undefined' || (typeof error.errorcode != 'undefined' && + error.errorcode != 'invalidtoken' && error.errorcode != 'userdeleted' && error.errorcode != 'upgraderunning' && + error.errorcode != 'forcepasswordchangenotice' && error.errorcode != 'usernotfullysetup' && + error.errorcode != 'sitepolicynotagreed' && error.errorcode != 'sitemaintenance' && + (error.errorcode != 'accessexception' || error.message.indexOf('Invalid token - token expired') == -1)); } /**