From 382a880a29a1e5c36dec7246088d5f30d4a0e54e Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sat, 10 Aug 2024 18:25:00 +1200 Subject: [PATCH] update path to peer when a message is sent or received --- .../messages/ConversationViewer.vue | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/frontend/components/messages/ConversationViewer.vue b/src/frontend/components/messages/ConversationViewer.vue index 0b98966..df2af97 100644 --- a/src/frontend/components/messages/ConversationViewer.vue +++ b/src/frontend/components/messages/ConversationViewer.vue @@ -449,7 +449,7 @@ export default { return; } - this.getPeerPath(this.selectedPeer.destination_hash); + this.getPeerPath(); // load 1 page of previous messages await this.loadPrevious(); @@ -520,10 +520,12 @@ export default { switch(json.type){ case 'lxmf.delivery': { this.onLxmfMessageReceived(json.lxmf_message); + await this.getPeerPath(); break; } case 'lxmf_message_created': { this.onLxmfMessageCreated(json.lxmf_message); + await this.getPeerPath(); break; } case 'lxmf_message_state_updated': { @@ -601,21 +603,23 @@ export default { }); } }, - async getPeerPath(destinationHash) { + async getPeerPath() { // clear previous known path this.selectedPeerPath = null; - try { + if(this.selectedPeer){ + try { - // get path to destination - const response = await window.axios.get(`/api/v1/destination/${destinationHash}/path`); + // get path to destination + const response = await window.axios.get(`/api/v1/destination/${this.selectedPeer.destination_hash}/path`); - // update ui - this.selectedPeerPath = response.data.path; + // update ui + this.selectedPeerPath = response.data.path; - } catch(e) { - console.log(e); + } catch(e) { + console.log(e); + } } },