From 26e63e4ab23808e1789acd92cd9a750c375a13df Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 2 Dec 2019 06:42:48 -0400 Subject: [PATCH] Use new nio AsyncClient.mxc_to_http() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Has the correct behavior for all servers, e.g. mxc://privacytoosl.io/id → https://chat.privacytools.io/... --- TODO.md | 7 ++++--- src/python/backend.py | 5 ----- src/python/media_cache.py | 5 ----- src/qml/Chat/Timeline/EventImage.qml | 3 ++- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/TODO.md b/TODO.md index 964ba087..02dcbcb7 100644 --- a/TODO.md +++ b/TODO.md @@ -1,8 +1,9 @@ - Media - - Verify things work with chat.privacytools.io (subdomain weirdness) + - Upload progression and pausing - Confirmation box after picking file to upload - - Handle upload/set avatar errors: bad path, is a dir, file too big, etc - - Show real progression for mxc thumbnail loadings, uploads and downloads + - Handle set avatar upload errors + - Show real progression for mxc thumbnail loadings + - Support encrypted m.file - Show reason under broken thumbnail icons - Support m.file thumbnails diff --git a/src/python/backend.py b/src/python/backend.py index df105e41..27e98d02 100644 --- a/src/python/backend.py +++ b/src/python/backend.py @@ -136,11 +136,6 @@ class Backend: return hsluv.hsluv_to_rgb([hue, saturation, lightness]) - @staticmethod - async def mxc_to_http(mxc: str) -> Optional[str]: - return nio.Api.mxc_to_http(mxc) - - async def load_settings(self) -> tuple: from .config_files import Theme settings = await self.ui_settings.read() diff --git a/src/python/media_cache.py b/src/python/media_cache.py index b05c75f3..69730290 100644 --- a/src/python/media_cache.py +++ b/src/python/media_cache.py @@ -40,11 +40,6 @@ class Media: raise ValueError(f"Invalid mxc URI: {self.mxc}") - @property - def http(self) -> str: - return nio.Api.mxc_to_http(self.mxc) - - @property def local_path(self) -> Path: parsed = urlparse(self.mxc) diff --git a/src/qml/Chat/Timeline/EventImage.qml b/src/qml/Chat/Timeline/EventImage.qml index 632340df..53cd4131 100644 --- a/src/qml/Chat/Timeline/EventImage.qml +++ b/src/qml/Chat/Timeline/EventImage.qml @@ -57,7 +57,8 @@ HMxcImage { let isMxc = toOpen.startsWith("mxc://") isMxc ? - py.callCoro("mxc_to_http", [toOpen], callback) : callback(toOpen) + py.callClientCoro(chatPage.userId, "mxc_to_http", [toOpen], callback) : + callback(toOpen) }