From 1504bec4dc971eefef4286ea1517a565e81b21ac Mon Sep 17 00:00:00 2001 From: liamcottle Date: Wed, 18 Sep 2024 19:46:56 +1200 Subject: [PATCH] ensure propagation node is configured before attempting to sync --- meshchat.py | 6 ++++++ src/frontend/components/App.vue | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/meshchat.py b/meshchat.py index cf69428..19f136f 100644 --- a/meshchat.py +++ b/meshchat.py @@ -840,6 +840,12 @@ class ReticulumMeshChat: @routes.get("/api/v1/lxmf/propagation-node/sync") async def index(request): + # ensure propagation node is configured before attempting to sync + if self.message_router.get_outbound_propagation_node() is None: + return web.json_response({ + "message": "A propagation node must be configured to sync messages.", + }, status=400) + # request messages from propagation node self.message_router.request_messages_from_propagation_node(self.identity) diff --git a/src/frontend/components/App.vue b/src/frontend/components/App.vue index 97321c5..2176805 100644 --- a/src/frontend/components/App.vue +++ b/src/frontend/components/App.vue @@ -406,11 +406,15 @@ export default { // request sync try { await axios.get("/api/v1/lxmf/propagation-node/sync"); - await this.updatePropagationNodeStatus(); } catch(e) { - DialogUtils.alert("Failed to sync propagation node"); + const errorMessage = e.response?.data?.message ?? "Something went wrong. Try again later."; + DialogUtils.alert(errorMessage); + return; } + // update propagation status + await this.updatePropagationNodeStatus(); + // wait until sync has finished const syncFinishedInterval = setInterval(() => {