From 451038641e22c4fd01c0c07a02d17d4c20e0ede2 Mon Sep 17 00:00:00 2001 From: miruka Date: Sat, 14 Sep 2019 00:46:33 -0400 Subject: [PATCH] Display RoomMessageImage events --- TODO.md | 8 ++++++++ src/python/matrix_client.py | 23 +++++++++++++---------- src/python/models/items.py | 6 +++--- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/TODO.md b/TODO.md index 62c70ebb..3a691f57 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1,10 @@ +- Media + - Caching + - Downloading + - Files, links, video, audio + - Encrypted media + - Loading animation + - Refactoring - Room header elide detection - Use HBox for Profile @@ -13,6 +20,7 @@ - When qml syntax highlighting supports ES6 string interpolation, use that - Fixes + - GIF glitchy border - When selecting text and scrolling up, selection stops working after a while - Ensure all the text that should be copied is copied diff --git a/src/python/matrix_client.py b/src/python/matrix_client.py index 8af7e4e8..3aba0538 100644 --- a/src/python/matrix_client.py +++ b/src/python/matrix_client.py @@ -625,16 +625,19 @@ class MatrixClient(nio.AsyncClient): await self.register_nio_event( room, ev, - content = "", - inline_content = ev.body, - media_url = ev.url, - media_title = ev.body, - media_width = info.get("w") or 0, - media_height = info.get("h") or 0, - media_duration = info.get("duration") or 0, - media_size = info.get("size") or 0, - media_mime = info.get("mimetype") or 0, - thumbnail_url = info.get("thumbnail_url") or "", + content = "", + inline_content = ev.body, + media_url = nio.Api.mxc_to_http(ev.url), + media_title = ev.body, + media_width = info.get("w") or 0, + media_height = info.get("h") or 0, + media_duration = info.get("duration") or 0, + media_size = info.get("size") or 0, + media_mime = info.get("mimetype") or 0, + + thumbnail_url = + nio.Api.mxc_to_http(info.get("thumbnail_url") or ""), + thumbnail_width = thumb_info.get("w") or 0, thumbnail_height = thumb_info.get("h") or 0, ) diff --git a/src/python/models/items.py b/src/python/models/items.py index 622f5893..0149f4e0 100644 --- a/src/python/models/items.py +++ b/src/python/models/items.py @@ -162,12 +162,12 @@ class Event(ModelItem): @property def links(self) -> List[str]: - if not self.content.strip(): - return [] - if isinstance(self.source, nio.RoomMessageMedia): return [self.media_url] + if not self.content.strip(): + return [] + return [link[2] for link in lxml.html.iterlinks(self.content)]