From 52cd539f93ade313b48f3ad4aa00fe8ac6995776 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Mon, 29 Apr 2024 20:41:50 +1200 Subject: [PATCH] show peers and be able to reply to them --- index.html | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index d07ff07..33d8f6e 100644 --- a/index.html +++ b/index.html @@ -61,6 +61,12 @@ +
+
+ <{{ peer.destination_hash }}> {{ peer.app_data }} +
+
+
@@ -142,12 +148,12 @@ isWebsocketConnected: false, autoReconnectWebsocket: true, - sendToDestinationHash: "bebfd1f0635a7f6129ee3b30c05328f3", - newMessageText: "", isSendingMessage: false, autoScrollOnNewMessage: true, + peers: {}, + selectedPeer: null, chatItems: [], }; @@ -178,6 +184,13 @@ this.ws.onmessage = (message) => { const json = JSON.parse(message.data); switch(json.type){ + case 'announce': { + this.peers[json.destination_hash] = { + destination_hash: json.destination_hash, + app_data: json.app_data, + } + break; + } case 'lxmf.delivery': { this.chatItems.push({ "source_hash": json.source_hash, @@ -237,6 +250,11 @@ return; } + // do nothing if no peer selected + if(!this.selectedPeer){ + return; + } + this.isSendingMessage = true; try { @@ -244,7 +262,7 @@ // send message to reticulum via websocket this.ws.send(JSON.stringify({ "type": "lxmf.delivery", - "destination_hash": this.sendToDestinationHash, + "destination_hash": this.selectedPeer.destination_hash, "message": messageText, })); @@ -308,6 +326,9 @@ window.open(fileUrl); }, + onPeerClick: function(peer) { + this.selectedPeer = peer; + }, }, computed: { isMobile() {