mirror of
https://github.com/aljazceru/meshcore-web.git
synced 2025-12-18 16:44:21 +01:00
add button to export contact to clipboard as meshcore://<hex> url
This commit is contained in:
@@ -41,6 +41,14 @@
|
|||||||
<span>Share (Zero Hop Advert)</span>
|
<span>Share (Zero Hop Advert)</span>
|
||||||
</DropDownMenuItem>
|
</DropDownMenuItem>
|
||||||
|
|
||||||
|
<!-- export contact button -->
|
||||||
|
<DropDownMenuItem @click="exportContact(contact)">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-5">
|
||||||
|
<path fill-rule="evenodd" d="M15.75 4.5a3 3 0 1 1 .825 2.066l-8.421 4.679a3.002 3.002 0 0 1 0 1.51l8.421 4.679a3 3 0 1 1-.729 1.31l-8.421-4.678a3 3 0 1 1 0-4.132l8.421-4.679a3 3 0 0 1-.096-.755Z" clip-rule="evenodd" />
|
||||||
|
</svg>
|
||||||
|
<span>Export to Clipboard</span>
|
||||||
|
</DropDownMenuItem>
|
||||||
|
|
||||||
<!-- reset path button -->
|
<!-- reset path button -->
|
||||||
<DropDownMenuItem @click="onResetPath(contact)">
|
<DropDownMenuItem @click="onResetPath(contact)">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
|
||||||
@@ -104,6 +112,17 @@ export default {
|
|||||||
alert("Failed to share this contact!");
|
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) {
|
async onResetPath(contact) {
|
||||||
|
|
||||||
// confirm user wants to reset path
|
// confirm user wants to reset path
|
||||||
|
|||||||
@@ -195,6 +195,10 @@ class Connection {
|
|||||||
await GlobalState.connection.shareContact(publicKey);
|
await GlobalState.connection.shareContact(publicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async exportContact(publicKey) {
|
||||||
|
return await GlobalState.connection.exportContact(publicKey);
|
||||||
|
}
|
||||||
|
|
||||||
static async sendMessage(publicKey, text) {
|
static async sendMessage(publicKey, text) {
|
||||||
|
|
||||||
// send message
|
// send message
|
||||||
|
|||||||
Reference in New Issue
Block a user