ensure propagation node is configured before attempting to sync

This commit is contained in:
liamcottle 2024-09-18 19:46:56 +12:00
commit 1504bec4dc
2 changed files with 12 additions and 2 deletions

View file

@ -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)

View file

@ -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(() => {