From e800ce054b55f9ded6d83d3ac4e6aeb81cda5bc3 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 19 Mar 2024 11:05:00 +0100 Subject: [PATCH] Added message transfer progress indication --- sbapp/sideband/core.py | 7 +++++++ sbapp/ui/messages.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index bacd598..47258f9 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -3248,6 +3248,13 @@ class SidebandCore(): RNS.log("Error while creating paper message: "+str(e), RNS.LOG_ERROR) return False + def get_lxm_progress(self, lxm_hash): + try: + return self.message_router.get_outbound_progress(lxm_hash) + except Exception as e: + RNS.log("An error occurred while getting message transfer progress: "+str(e), RNS.LOG_ERROR) + return None + def send_message(self, content, destination_hash, propagation, skip_fields=False, no_display=False, attachment = None, image = None, audio = None): try: if content == "": diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py index 97160c9..c83387c 100644 --- a/sbapp/ui/messages.py +++ b/sbapp/ui/messages.py @@ -135,6 +135,20 @@ class Messages(): if m["state"] == LXMF.LXMessage.SENDING or m["state"] == LXMF.LXMessage.OUTBOUND: msg = self.app.sideband.message(m["hash"]) + + if msg["state"] == LXMF.LXMessage.OUTBOUND or msg["state"] == LXMF.LXMessage.SENDING: + w.md_bg_color = msg_color = mdc(color_unknown, intensity_msgs) + txstr = time.strftime(ts_format, time.localtime(msg["sent"])) + titlestr = "" + prgstr = "" + prg = self.app.sideband.get_lxm_progress(msg["hash"]) + if prg != None: + prgstr = ", "+str(round(prg*100, 1))+"% progress" + if msg["title"]: + titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n" + w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Sending"+prgstr+" " + m["state"] = msg["state"] + if msg["state"] == LXMF.LXMessage.DELIVERED: w.md_bg_color = msg_color = mdc(color_delivered, intensity_msgs) txstr = time.strftime(ts_format, time.localtime(msg["sent"]))