From 79fdc710c342c0d6ea1b79ff7a4d502d4b74fbde Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 10 Jul 2020 12:27:06 -0400 Subject: [PATCH] Fix & improve send_file handling of offline account - Show a transfer stuck at 0kb uploaded in the GUI instead of waiting to be online to show anything - Fix getting online not making the upload start --- TODO.md | 1 + src/backend/matrix_client.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/TODO.md b/TODO.md index fbc9730c..023364ec 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,6 @@ # TODO +- retry if media not found - fix members not synced bug - fix local unread counters order - warn about no E2E room shared if no devices diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 64bb6392..b499d905 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -551,10 +551,6 @@ class MatrixClient(nio.AsyncClient): async def send_file(self, room_id: str, path: Union[Path, str]) -> None: """Send a `m.file`, `m.image`, `m.audio` or `m.video` message.""" - presence = self.models["accounts"][self.user_id].presence - while presence == Presence.State.offline: - await asyncio.sleep(0.2) - item_uuid = uuid4() try: @@ -604,6 +600,12 @@ class MatrixClient(nio.AsyncClient): monitor.on_transferred = on_transferred monitor.on_speed_changed = on_speed_changed + while ( + self.models["accounts"][self.user_id].presence == + Presence.State.offline + ): + await asyncio.sleep(0.2) + try: url, mime, crypt_dict = await self.upload( lambda *_: path,