diff --git a/src/frontend/components/App.vue b/src/frontend/components/App.vue index 9d101e9..97321c5 100644 --- a/src/frontend/components/App.vue +++ b/src/frontend/components/App.vue @@ -14,6 +14,16 @@
Developed by Liam Cottle
+
@@ -278,6 +288,7 @@ export default { appInfo: null, audioCalls: [], + propagationNodeStatus: null, }; }, @@ -296,11 +307,12 @@ export default { this.getAppInfo(); this.updateCallsList(); + this.updatePropagationNodeStatus(); - // fixme: clear interval on unmount // update info every few seconds this.reloadInterval = setInterval(() => { this.updateCallsList(); + this.updatePropagationNodeStatus(); }, 3000); }, @@ -384,6 +396,52 @@ export default { GlobalEmitter.emit("compose-new-message"); }, + async syncPropagationNode() { + + // do nothing if already syncing + if(this.isSyncingPropagationNode){ + return; + } + + // request sync + try { + await axios.get("/api/v1/lxmf/propagation-node/sync"); + await this.updatePropagationNodeStatus(); + } catch(e) { + DialogUtils.alert("Failed to sync propagation node"); + } + + // wait until sync has finished + const syncFinishedInterval = setInterval(() => { + + // do nothing if still syncing + if(this.isSyncingPropagationNode){ + return; + } + + // finished syncing, stop checking + clearInterval(syncFinishedInterval); + + // show result + const status = this.propagationNodeStatus?.state; + const messagesReceived = this.propagationNodeStatus?.messages_received ?? 0; + if(status === "complete"){ + DialogUtils.alert(`Sync complete. ${messagesReceived} messages received.`); + } else { + DialogUtils.alert(`Sync error: ${status}`); + } + + }, 500); + + }, + async updatePropagationNodeStatus() { + try { + const response = await axios.get("/api/v1/lxmf/propagation-node/status"); + this.propagationNodeStatus = response.data.propagation_node_status; + } catch(e) { + // do nothing on error + } + }, formatSecondsAgo: function(seconds) { return Utils.formatSecondsAgo(seconds); }, @@ -448,6 +506,16 @@ export default { return audioCall.is_outbound; }); }, + isSyncingPropagationNode() { + return [ + "path_requested", + "link_establishing", + "link_established", + "request_sent", + "receiving", + "response_received", + ].includes(this.propagationNodeStatus?.state); + }, }, }