mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	added ability to kill unfinished deferred queue (need to make this generic)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									5258797173
								
							
						
					
					
						commit
						9c5b61ef22
					
				
							
								
								
									
										32
									
								
								ui/files.js
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								ui/files.js
									
									
									
									
									
								
							| @ -713,18 +713,40 @@ function updateImagesOrientation(gids, no_update_loaded){ | |||||||
| // XXX need a way to cancel this...
 | // XXX need a way to cancel this...
 | ||||||
| // 		- one way is to .reject(...) any of the still pending elements,
 | // 		- one way is to .reject(...) any of the still pending elements,
 | ||||||
| // 		  but there appears no way of getting the list out of when...
 | // 		  but there appears no way of getting the list out of when...
 | ||||||
|  | //
 | ||||||
| function updateImagesOrientationQ(gids, no_update_loaded){ | function updateImagesOrientationQ(gids, no_update_loaded){ | ||||||
| 	gids = gids == null ? getClosestGIDs() : gids | 	gids = gids == null ? getClosestGIDs() : gids | ||||||
| 	//var res = []
 | 	//var res = []
 | ||||||
| 
 | 
 | ||||||
| 	var last = $.Deferred().resolve() | 	var last = $.Deferred().resolve() | ||||||
| 
 | 
 | ||||||
|  | 	// this is used for two things:
 | ||||||
|  | 	// 	- report progress
 | ||||||
|  | 	// 	- kill the queue if needed...
 | ||||||
|  | 	var monitor = $.Deferred() | ||||||
|  | 	monitor.killed = false | ||||||
|  | 	monitor.kill = function(){ | ||||||
|  | 		this.killed = true | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	$.each(gids, function(_, gid){ | 	$.each(gids, function(_, gid){ | ||||||
| 		var cur = $.Deferred() | 		var cur = $.Deferred() | ||||||
| 		last.done(function(){ | 		last.done(function(){ | ||||||
|  | 			if(monitor.killed == true){ | ||||||
|  | 				monitor.notify('killed') | ||||||
|  | 				monitor.resolve() | ||||||
|  | 				cur.reject()  | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
| 			updateImageOrientation(gid, no_update_loaded) | 			updateImageOrientation(gid, no_update_loaded) | ||||||
| 				.done(function(o){ cur.resolve(o) }) | 				.done(function(o){  | ||||||
| 				.fail(function(){ cur.resolve('fail') }) | 					cur.resolve(o)  | ||||||
|  | 					monitor.notify('done', gid) | ||||||
|  | 				}) | ||||||
|  | 				.fail(function(){  | ||||||
|  | 					cur.resolve('fail')  | ||||||
|  | 					monitor.notify('fail', gid) | ||||||
|  | 				}) | ||||||
| 		}) | 		}) | ||||||
| 
 | 
 | ||||||
| 		last = cur | 		last = cur | ||||||
| @ -733,7 +755,11 @@ function updateImagesOrientationQ(gids, no_update_loaded){ | |||||||
| 
 | 
 | ||||||
| 	// NOTE: .when(...) is used to add more introspecitve feedback...
 | 	// NOTE: .when(...) is used to add more introspecitve feedback...
 | ||||||
| 	//return $.when.apply(null, res)
 | 	//return $.when.apply(null, res)
 | ||||||
| 	return last | 	// return last
 | ||||||
|  | 	last.done(function(){ | ||||||
|  | 		monitor.resolve() | ||||||
|  | 	}) | ||||||
|  | 	return monitor | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user