Merge pull request #1427 from dpalou/MOBILE-2399
MOBILE-2399 url: Fix URL variables not used
This commit is contained in:
		
						commit
						47e24294e4
					
				| @ -63,10 +63,11 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo | |||||||
|      * @return {Promise<any>} Promise resolved when done. |      * @return {Promise<any>} Promise resolved when done. | ||||||
|      */ |      */ | ||||||
|     protected fetchContent(refresh?: boolean): Promise<any> { |     protected fetchContent(refresh?: boolean): Promise<any> { | ||||||
|         let canGetUrl = this.canGetUrl; |         let canGetUrl = this.canGetUrl, | ||||||
|  |             mod, | ||||||
|  |             promise; | ||||||
| 
 | 
 | ||||||
|         // Fetch the module data.
 |         // Fetch the module data.
 | ||||||
|         let promise; |  | ||||||
|         if (canGetUrl) { |         if (canGetUrl) { | ||||||
|             promise = this.urlProvider.getUrl(this.courseId, this.module.id); |             promise = this.urlProvider.getUrl(this.courseId, this.module.id); | ||||||
|         } else { |         } else { | ||||||
| @ -76,21 +77,30 @@ export class AddonModUrlIndexComponent extends CoreCourseModuleMainResourceCompo | |||||||
|         return promise.catch(() => { |         return promise.catch(() => { | ||||||
|             canGetUrl = false; |             canGetUrl = false; | ||||||
| 
 | 
 | ||||||
|             // Fallback in case is not prefetch or not avalaible.
 |             // Fallback in case is not prefetched or not available.
 | ||||||
|             return this.courseProvider.getModule(this.module.id, this.courseId); |             return this.courseProvider.getModule(this.module.id, this.courseId); | ||||||
|         }).then((url) => { |         }).then((url) => { | ||||||
|  |             this.description = url.intro || url.description; | ||||||
|  |             this.dataRetrieved.emit(url); | ||||||
|  | 
 | ||||||
|             if (!canGetUrl) { |             if (!canGetUrl) { | ||||||
|  |                 mod = url; | ||||||
|  | 
 | ||||||
|                 if (!url.contents.length) { |                 if (!url.contents.length) { | ||||||
|                     // If the data was cached maybe we don't have contents. Reject.
 |                     // If the data was cached maybe we don't have contents. Reject.
 | ||||||
|                     return Promise.reject(null); |                     return Promise.reject(null); | ||||||
|                 } |                 } | ||||||
|  |             } else { | ||||||
|  |                 mod = this.module; | ||||||
|  | 
 | ||||||
|  |                 if (!mod.contents || !mod.contents.length) { | ||||||
|  |                     // Try to load module contents, it's needed to get the URL with parameters.
 | ||||||
|  |                     return this.courseProvider.loadModuleContents(mod, this.courseId); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
| 
 |         }).then(() => { | ||||||
|             this.description = url.intro || url.description; |             // Always use the URL from the module because it already includes the parameters.
 | ||||||
|             this.dataRetrieved.emit(url); |             this.url = mod.contents && mod.contents[0] && mod.contents[0].fileurl ? mod.contents[0].fileurl : undefined; | ||||||
| 
 |  | ||||||
|             this.url = canGetUrl ? url.externalurl : |  | ||||||
|                             ((url.contents[0] && url.contents[0].fileurl) ? url.contents[0].fileurl : undefined); |  | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user