From 2ecdf1c8532a0dc33f56a751d12b3b59a14e4fda Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Mon, 16 Sep 2024 18:59:33 +0200 Subject: [PATCH] Send messages opportunistically if ratchets are available --- sbapp/sideband/core.py | 6 +++++- sbapp/ui/messages.py | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sbapp/sideband/core.py b/sbapp/sideband/core.py index 8c7d11e..fd83777 100644 --- a/sbapp/sideband/core.py +++ b/sbapp/sideband/core.py @@ -4067,7 +4067,11 @@ class SidebandCore(): if propagation: desired_method = LXMF.LXMessage.PROPAGATED else: - desired_method = LXMF.LXMessage.DIRECT + if not self.message_router.delivery_link_available(destination_hash) and RNS.Identity.current_ratchet_id(destination_hash) != None: + RNS.log(f"Have ratchet for {RNS.prettyhexrep(destination_hash)}, requesting opportunistic delivery of message", RNS.LOG_DEBUG) + desired_method = LXMF.LXMessage.OPPORTUNISTIC + else: + desired_method = LXMF.LXMessage.DIRECT if skip_fields: fields = {} diff --git a/sbapp/ui/messages.py b/sbapp/ui/messages.py index bfc0954..70a0d2a 100644 --- a/sbapp/ui/messages.py +++ b/sbapp/ui/messages.py @@ -102,7 +102,6 @@ class Messages(): self.list.remove_widget(self.load_more_button) def message_details_dialog(self, lxm_hash): - RNS.log(f"Opening dialog for {RNS.prettyhexrep(lxm_hash)}", RNS.LOG_DEBUG) ss = int(dp(16)) ms = int(dp(14)) @@ -247,10 +246,10 @@ class Messages(): else: w.line_color = (1.0, 1.0, 1.0, 0.5) - if m["state"] == LXMF.LXMessage.SENDING or m["state"] == LXMF.LXMessage.OUTBOUND: + if m["state"] == LXMF.LXMessage.SENDING or m["state"] == LXMF.LXMessage.OUTBOUND or m["state"] == LXMF.LXMessage.SENT: msg = self.app.sideband.message(m["hash"]) - if msg["state"] == LXMF.LXMessage.OUTBOUND or msg["state"] == LXMF.LXMessage.SENDING: + if msg["state"] == LXMF.LXMessage.OUTBOUND or msg["state"] == LXMF.LXMessage.SENDING or msg["state"] == LXMF.LXMessage.SENT: w.md_bg_color = msg_color = mdc(color_unknown, intensity_msgs) txstr = time.strftime(ts_format, time.localtime(msg["sent"])) titlestr = ""