Added retry option on failed messages

This commit is contained in:
Mark Qvist 2023-10-16 22:21:38 +02:00
parent bab5bd014e
commit 4a6dfa4a47
1 changed files with 52 additions and 14 deletions

View File

@ -149,6 +149,7 @@ class Messages():
titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n" titlestr = "[b]Title[/b] "+msg["title"].decode("utf-8")+"\n"
w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Failed" w.heading = titlestr+"[b]Sent[/b] "+txstr+"\n[b]State[/b] Failed"
m["state"] = msg["state"] m["state"] = msg["state"]
w.dmenu.items.append(w.dmenu.retry_item)
def update_widget(self): def update_widget(self):
@ -240,6 +241,18 @@ class Messages():
dialog.open() dialog.open()
return x return x
def gen_retry(mhash, mcontent, item):
def x():
self.app.root.ids.message_text.text = mcontent.decode("utf-8")
self.app.sideband.delete_message(mhash)
self.app.message_send_action()
item.dmenu.dismiss()
def cb(dt):
self.reload()
Clock.schedule_once(cb, 0.2)
return x
def gen_copy(msg, item): def gen_copy(msg, item):
def x(): def x():
Clipboard.copy(msg) Clipboard.copy(msg)
@ -346,6 +359,12 @@ class Messages():
return x return x
retry_item = {
"viewclass": "OneLineListItem",
"text": "Retry",
"height": dp(40),
"on_release": gen_retry(m["hash"], m["content"], item)
}
if m["method"] == LXMF.LXMessage.PAPER: if m["method"] == LXMF.LXMessage.PAPER:
if RNS.vendor.platformutils.is_android(): if RNS.vendor.platformutils.is_android():
qr_save_text = "Share QR Code" qr_save_text = "Share QR Code"
@ -411,7 +430,9 @@ class Messages():
] ]
else: else:
if m["state"] == LXMF.LXMessage.FAILED:
dm_items = [ dm_items = [
retry_item,
{ {
"viewclass": "OneLineListItem", "viewclass": "OneLineListItem",
"text": "Copy", "text": "Copy",
@ -425,6 +446,22 @@ class Messages():
"on_release": gen_del(m["hash"], item) "on_release": gen_del(m["hash"], item)
} }
] ]
else:
dm_items = [
{
"viewclass": "OneLineListItem",
"text": "Copy",
"height": dp(40),
"on_release": gen_copy(m["content"].decode("utf-8"), item)
},
{
"text": "Delete",
"viewclass": "OneLineListItem",
"height": dp(40),
"on_release": gen_del(m["hash"], item)
}
]
item.dmenu = MDDropdownMenu( item.dmenu = MDDropdownMenu(
caller=item.ids.msg_submenu, caller=item.ids.msg_submenu,
@ -434,6 +471,7 @@ class Messages():
elevation=0, elevation=0,
radius=dp(3), radius=dp(3),
) )
item.dmenu.retry_item = retry_item
def callback_factory(ref): def callback_factory(ref):
def x(sender): def x(sender):