Handle nio.ThumbnailError cases

Return a 1x1 transparent PNG for now.
This commit is contained in:
miruka 2019-07-18 02:08:01 -04:00
parent 44a998f31b
commit 4c0b947d1a
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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"):