forked from EVOgeek/Vmeda.Online
		
	MOBILE-3068 core: Fix img loaded event if no URL
This commit is contained in:
		
							parent
							
								
									06f4b0ed48
								
							
						
					
					
						commit
						ebd4577be2
					
				| @ -152,12 +152,22 @@ export class CoreExternalContentDirective implements AfterViewInit, OnChanges { | ||||
|         // Avoid handling data url's.
 | ||||
|         if (url && url.indexOf('data:') === 0) { | ||||
|             this.invalid = true; | ||||
|             this.onLoad.emit(); | ||||
|             this.loaded = true; | ||||
| 
 | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         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); | ||||
|             } | ||||
| 
 | ||||
|             if (tagName === 'IMG') { | ||||
|                 this.waitForLoad(); | ||||
|             } | ||||
| 
 | ||||
|             return Promise.reject(null); | ||||
|         } | ||||
| 
 | ||||
|  | ||||
| @ -468,7 +468,8 @@ export class CoreFormatTextDirective implements OnChanges { | ||||
|             // Wait for images to load.
 | ||||
|             let promise: Promise<any> = null; | ||||
|             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) { | ||||
|                         // Image has already been loaded, no need to wait.
 | ||||
|                         return Promise.resolve(); | ||||
| @ -480,7 +481,7 @@ export class CoreFormatTextDirective implements OnChanges { | ||||
|                             resolve(); | ||||
|                         }); | ||||
|                     }); | ||||
|                 })); | ||||
|                 })), 5000); | ||||
|             } else { | ||||
|                 promise = Promise.resolve(); | ||||
|             } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user