From fa056987b5d4251ccbddd664e8f8bff116d91d69 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sat, 15 Feb 2025 23:58:50 +1300 Subject: [PATCH] add button to export contact to clipboard as meshcore:// url --- .../contacts/ContactDropDownMenu.vue | 19 +++++++++++++++++++ src/js/Connection.js | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/components/contacts/ContactDropDownMenu.vue b/src/components/contacts/ContactDropDownMenu.vue index b00e266..fb29f54 100644 --- a/src/components/contacts/ContactDropDownMenu.vue +++ b/src/components/contacts/ContactDropDownMenu.vue @@ -41,6 +41,14 @@ Share (Zero Hop Advert) + + + + + + Export to Clipboard + + @@ -104,6 +112,17 @@ export default { alert("Failed to share this contact!"); } }, + async exportContact(contact) { + try { + const exportedContact = await Connection.exportContact(contact.publicKey); + const advertPacketAsHex = Utils.bytesToHex(exportedContact.advertPacketBytes); + const meshCoreContactUrl = `meshcore://${advertPacketAsHex}`; + await Utils.copyToClipboard(meshCoreContactUrl); + } catch(e) { + console.log(e); + alert("Failed to export this contact!"); + } + }, async onResetPath(contact) { // confirm user wants to reset path diff --git a/src/js/Connection.js b/src/js/Connection.js index 67bcc37..105a9a9 100644 --- a/src/js/Connection.js +++ b/src/js/Connection.js @@ -195,6 +195,10 @@ class Connection { await GlobalState.connection.shareContact(publicKey); } + static async exportContact(publicKey) { + return await GlobalState.connection.exportContact(publicKey); + } + static async sendMessage(publicKey, text) { // send message