From 8c011dd72ff980a23cd2f0ab2ac0bb8955d0d31a Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 8 Jul 2024 22:04:22 +1200 Subject: [PATCH] add button to retry sending failed messages --- public/index.html | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/public/index.html b/public/index.html index 5ebb3dc..106bc6c 100644 --- a/public/index.html +++ b/public/index.html @@ -601,6 +601,7 @@ {{ chatItem.lxmf_message.state }} (attempt {{ chatItem.lxmf_message.delivery_attempts + 1 }}) {{ chatItem.lxmf_message.progress.toFixed(0) }}% + retry? @@ -1672,6 +1673,36 @@ // scroll to bottom this.scrollMessagesToBottom(); + }, + async retrySendingMessage(chatItem) { + + // do nothing if not connected to websocket + if(!this.isWebsocketConnected){ + this.alert("Not connected to WebSocket!"); + return; + } + + // force delete existing message + await this.deleteChatItem(chatItem, false); + + try { + + // send message to reticulum via websocket + this.ws.send(JSON.stringify({ + "type": "lxmf.delivery", + "lxmf_message": chatItem.lxmf_message, + })); + + } catch(e) { + + // todo handle error + console.error(e); + + } + + // scroll to bottom + this.scrollMessagesToBottom(); + }, async updateConfig(config) { @@ -2246,11 +2277,11 @@ this.alert("unsupported url: " + url); }, - async deleteChatItem(chatItem) { + async deleteChatItem(chatItem, shouldConfirm = true) { try { // ask user to confirm deleting message - if(!confirm("Are you sure you want to delete this message? This can not be undone!")){ + if(shouldConfirm && !confirm("Are you sure you want to delete this message? This can not be undone!")){ return; }