From 49966e06ad0dabbd435bf97008fd961e64f31902 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 9 Mar 2020 17:36:47 -0400 Subject: [PATCH] Fix Transfer.time_left that could be None --- src/backend/matrix_client.py | 4 ++-- src/gui/Pages/Chat/FileTransfer/Transfer.qml | 2 +- src/gui/PythonBridge/Privates/EventHandlers.qml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 11152861..a5acdace 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -11,7 +11,7 @@ import re import traceback from contextlib import suppress from copy import copy -from datetime import datetime +from datetime import datetime, timedelta from functools import partial from pathlib import Path from typing import ( @@ -381,7 +381,7 @@ class MatrixClient(nio.AsyncClient): def on_speed_changed(speed: float) -> None: upload_item.speed = speed - upload_item.time_left = monitor.remaining_time + upload_item.time_left = monitor.remaining_time or timedelta(0) monitor.on_transferred = on_transferred monitor.on_speed_changed = on_speed_changed diff --git a/src/gui/Pages/Chat/FileTransfer/Transfer.qml b/src/gui/Pages/Chat/FileTransfer/Transfer.qml index 57a5ba04..4d9b2cb3 100644 --- a/src/gui/Pages/Chat/FileTransfer/Transfer.qml +++ b/src/gui/Pages/Chat/FileTransfer/Transfer.qml @@ -9,7 +9,7 @@ HColumnLayout { id: transfer - property int msLeft: model.time_left || 0 + property int msLeft: model.time_left property int uploaded: model.uploaded readonly property int speed: model.speed readonly property int totalSize: model.total_size diff --git a/src/gui/PythonBridge/Privates/EventHandlers.qml b/src/gui/PythonBridge/Privates/EventHandlers.qml index 391395d5..98aa4b62 100644 --- a/src/gui/PythonBridge/Privates/EventHandlers.qml +++ b/src/gui/PythonBridge/Privates/EventHandlers.qml @@ -83,7 +83,7 @@ QtObject { function onModelItemFieldChanged(syncId, oldIndex, newIndex, field, value){ - print("\u001b[37mchange", syncId, oldIndex, newIndex, field, value, "\u001b[0m") + // print("change", syncId, oldIndex, newIndex, field, value) const model = ModelStore.get(syncId) model.setProperty(oldIndex, field, value)