Merge pull request #2079 from dpalou/MOBILE-3068
MOBILE-3068 core: Fix img loaded event if no URL
This commit is contained in:
		
						commit
						3c4ef6d8ca
					
				| @ -152,12 +152,22 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges { | |||||||
|         // Avoid handling data url's.
 |         // Avoid handling data url's.
 | ||||||
|         if (url && url.indexOf('data:') === 0) { |         if (url && url.indexOf('data:') === 0) { | ||||||
|             this.invalid = true; |             this.invalid = true; | ||||||
|  |             this.onLoad.emit(); | ||||||
|  |             this.loaded = true; | ||||||
| 
 | 
 | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         this.handleExternalContent(targetAttr, url, siteId).catch(() => { |         this.handleExternalContent(targetAttr, url, siteId).catch(() => { | ||||||
|             // Ignore errors.
 |             // Error handling content. Make sure the loaded event is triggered for images.
 | ||||||
|  |             if (tagName === 'IMG') { | ||||||
|  |                 if (url) { | ||||||
|  |                     this.waitForLoad(); | ||||||
|  |                 } else { | ||||||
|  |                     this.onLoad.emit(); | ||||||
|  |                     this.loaded = true; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         }); |         }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -204,10 +214,6 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges { | |||||||
|                 this.addSource(url); |                 this.addSource(url); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             if (tagName === 'IMG') { |  | ||||||
|                 this.waitForLoad(); |  | ||||||
|             } |  | ||||||
| 
 |  | ||||||
|             return Promise.reject(null); |             return Promise.reject(null); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -468,7 +468,8 @@ export class CoreFormatTextDirective implements OnChanges { | |||||||
|             // Wait for images to load.
 |             // Wait for images to load.
 | ||||||
|             let promise: Promise<any> = null; |             let promise: Promise<any> = null; | ||||||
|             if (externalImages.length) { |             if (externalImages.length) { | ||||||
|                 promise = Promise.all(externalImages.map((externalImage): any => { |                 // Automatically reject the promise after 5 seconds to prevent blocking the user forever.
 | ||||||
|  |                 promise = this.utils.timeoutPromise(this.utils.allPromises(externalImages.map((externalImage): any => { | ||||||
|                     if (externalImage.loaded) { |                     if (externalImage.loaded) { | ||||||
|                         // Image has already been loaded, no need to wait.
 |                         // Image has already been loaded, no need to wait.
 | ||||||
|                         return Promise.resolve(); |                         return Promise.resolve(); | ||||||
| @ -480,7 +481,7 @@ export class CoreFormatTextDirective implements OnChanges { | |||||||
|                             resolve(); |                             resolve(); | ||||||
|                         }); |                         }); | ||||||
|                     }); |                     }); | ||||||
|                 })); |                 })), 5000); | ||||||
|             } else { |             } else { | ||||||
|                 promise = Promise.resolve(); |                 promise = Promise.resolve(); | ||||||
|             } |             } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user