From e1b26d1ec7b1ffebb44666d5a4c7bd5174535b93 Mon Sep 17 00:00:00 2001 From: miruka Date: Sun, 8 Mar 2020 08:05:41 -0400 Subject: [PATCH] Show thumbnail uploading progress when uploading --- 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 7d9f1ad0..d129d1bf 100644 --- a/TODO.md +++ b/TODO.md @@ -9,7 +9,6 @@ - nio ClientTimeout - no thumb if bigger than original -- upload delay at the end? - Handle upload file size limit - Handle set avatar upload errors - Confirmation box after picking file to upload diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index c3828b12..e81714e6 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -418,9 +418,13 @@ class MatrixClient(nio.AsyncClient): upload_item.total_size = len(thumb_data) try: - # The total_size passed to the monitor only considers - # the file itself, and not the thumbnail. - monitor.on_transferred = None + upload_item.total_size = thumb_info.size + + monitor = nio.TransferMonitor(thumb_info.size) + monitor.on_transferred = on_transferred + monitor.on_speed_changed = on_speed_changed + + self.upload_monitors[item_uuid] = monitor thumb_url, _, thumb_crypt_dict = await self.upload( lambda *_: thumb_data,