commit
						c3ddf6e84f
					
				| @ -37,6 +37,7 @@ | ||||
|     <preference name="SplashMaintainAspectRatio" value="true" /> | ||||
|     <preference name="SplashShowOnlyFirstTime" value="false" /> | ||||
|     <preference name="LoadUrlTimeoutValue" value="60000" /> | ||||
|     <preference name="CustomURLSchemePluginClearsAndroidIntent" value="true" /> | ||||
|     <feature name="StatusBar"> | ||||
|         <param name="ios-package" onload="true" value="CDVStatusBar" /> | ||||
|     </feature> | ||||
|  | ||||
| @ -186,7 +186,7 @@ export class AddonModBookIndexComponent extends CoreCourseModuleMainResourceComp | ||||
|             // Chapter loaded, log view. We don't return the promise because we don't want to block the user for this.
 | ||||
|             this.bookProvider.logView(this.module.instance, chapterId, this.module.name).then(() => { | ||||
|                 // Module is completed when last chapter is viewed, so we only check completion if the last is reached.
 | ||||
|                 if (!this.nextChapter) { | ||||
|                 if (this.nextChapter == '0') { | ||||
|                     this.courseProvider.checkModuleCompletion(this.courseId, this.module.completiondata); | ||||
|                 } | ||||
|             }).catch(() => { | ||||
|  | ||||
| @ -680,6 +680,8 @@ export class CoreSite { | ||||
|                     (error.errorcode == 'accessexception' && error.message.indexOf('Invalid token - token expired') > -1)) { | ||||
|                     if (initialToken !== this.token && !retrying) { | ||||
|                         // Token has changed, retry with the new token.
 | ||||
|                         preSets.getFromCache = false; // Don't check cache now. Also, it will skip ongoingRequests.
 | ||||
| 
 | ||||
|                         return this.request(method, data, preSets, true); | ||||
|                     } else if (this.appProvider.isSSOAuthenticationOngoing()) { | ||||
|                         // There's an SSO authentication ongoing, wait for it to finish and try again.
 | ||||
|  | ||||
| @ -582,22 +582,48 @@ export class CoreSitesProvider { | ||||
|         } | ||||
| 
 | ||||
|         // Create a "candidate" site to fetch the site info.
 | ||||
|         const candidateSite = this.sitesFactory.makeSite(undefined, siteUrl, token, undefined, privateToken); | ||||
|         let candidateSite = this.sitesFactory.makeSite(undefined, siteUrl, token, undefined, privateToken), | ||||
|             isNewSite = true; | ||||
| 
 | ||||
|         return candidateSite.fetchSiteInfo().then((info) => { | ||||
|             const result = this.isValidMoodleVersion(info); | ||||
|             if (result == this.VALID_VERSION) { | ||||
|                 // Set site ID and info.
 | ||||
|                 const siteId = this.createSiteID(info.siteurl, info.username); | ||||
|                 candidateSite.setId(siteId); | ||||
|                 candidateSite.setInfo(info); | ||||
| 
 | ||||
|                 // Create database tables before login and before any WS call.
 | ||||
|                 return this.migrateSiteSchemas(candidateSite).then(() => { | ||||
|                 // Check if the site already exists.
 | ||||
|                 return this.getSite(siteId).catch(() => { | ||||
|                     // Not exists.
 | ||||
|                 }).then((site) => { | ||||
|                     if (site) { | ||||
|                         // Site already exists, update its data and use it.
 | ||||
|                         isNewSite = false; | ||||
|                         candidateSite = site; | ||||
|                         candidateSite.setToken(token); | ||||
|                         candidateSite.setPrivateToken(privateToken); | ||||
|                         candidateSite.setInfo(info); | ||||
| 
 | ||||
|                     } else { | ||||
|                         // New site, set site ID and info.
 | ||||
|                         isNewSite = true; | ||||
|                         candidateSite.setId(siteId); | ||||
|                         candidateSite.setInfo(info); | ||||
| 
 | ||||
|                         // Create database tables before login and before any WS call.
 | ||||
|                         return this.migrateSiteSchemas(candidateSite); | ||||
|                     } | ||||
| 
 | ||||
|                 }).then(() => { | ||||
| 
 | ||||
|                     // Try to get the site config.
 | ||||
|                     return this.getSiteConfig(candidateSite).then((config) => { | ||||
|                         candidateSite.setConfig(config); | ||||
|                     return this.getSiteConfig(candidateSite).catch((error) => { | ||||
|                         // Ignore errors if it's not a new site, we'll use the config already stored.
 | ||||
|                         if (isNewSite) { | ||||
|                             return Promise.reject(error); | ||||
|                         } | ||||
|                     }).then((config) => { | ||||
|                         if (typeof config != 'undefined') { | ||||
|                             candidateSite.setConfig(config); | ||||
|                         } | ||||
| 
 | ||||
|                         // Add site to sites list.
 | ||||
|                         this.addSite(siteId, siteUrl, token, info, privateToken, config); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user