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