Handle nio.ThumbnailError cases
Return a 1x1 transparent PNG for now.
This commit is contained in:
		
							
								
								
									
										3
									
								
								TODO.md
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								TODO.md
									
									
									
									
									
								
							| @@ -3,8 +3,6 @@ | ||||
| - Accent color from background | ||||
| - Reduce messages ListView cacheBuffer height once http thumbnails | ||||
|   downloading is implemented  | ||||
| - Button can get "hoverEnabled: false" to let HoverHandlers work | ||||
| - Handle thumbnail response status 400 | ||||
| - Improve avatar tooltips position, add stuff to room tooltips (last msg?) | ||||
| - Accept drag and dropping a picture in account settings to set avatar | ||||
| - When all the events loaded on beginning in a room are name/avatar changes, | ||||
| @@ -18,6 +16,7 @@ | ||||
| - Refactoring | ||||
|   - Don't bake in size properties for components | ||||
|   - Unfinished work in button-refactor branch | ||||
|     - Button can get "hoverEnabled: false" to let HoverHandlers work | ||||
|   - Room Sidepane | ||||
|  | ||||
| - Bug fixes | ||||
|   | ||||
| @@ -92,6 +92,13 @@ class Thumbnail: | ||||
|             height      = self.server_size[1], | ||||
|             method      = self.resize_method, | ||||
|         ) | ||||
|  | ||||
|         if isinstance(response, nio.ThumbnailError): | ||||
|             # Return a transparent 1x1 PNG | ||||
|             with BytesIO() as img_out: | ||||
|                 PILImage.new("RGBA", (1, 1), (0, 0, 0, 0)).save(img_out, "PNG") | ||||
|                 return img_out.getvalue() | ||||
|  | ||||
|         body = response.body | ||||
|  | ||||
|         if response.content_type not in ("image/jpeg", "image/png"): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	