add ability to share existing contacts

This commit is contained in:
liamcottle
2025-02-15 23:35:34 +13:00
parent dbbad7daae
commit c433abb9f5
2 changed files with 21 additions and 0 deletions

View File

@@ -33,6 +33,14 @@
<span>Copy Public Key</span> <span>Copy Public Key</span>
</DropDownMenuItem> </DropDownMenuItem>
<!-- share contact button -->
<DropDownMenuItem @click="shareContact(contact)">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-5">
<path fill-rule="evenodd" d="M5.636 4.575a.75.75 0 0 1 0 1.061 9 9 0 0 0 0 12.728.75.75 0 1 1-1.06 1.06c-4.101-4.1-4.101-10.748 0-14.849a.75.75 0 0 1 1.06 0Zm12.728 0a.75.75 0 0 1 1.06 0c4.101 4.1 4.101 10.75 0 14.85a.75.75 0 1 1-1.06-1.061 9 9 0 0 0 0-12.728.75.75 0 0 1 0-1.06ZM7.757 6.697a.75.75 0 0 1 0 1.06 6 6 0 0 0 0 8.486.75.75 0 0 1-1.06 1.06 7.5 7.5 0 0 1 0-10.606.75.75 0 0 1 1.06 0Zm8.486 0a.75.75 0 0 1 1.06 0 7.5 7.5 0 0 1 0 10.606.75.75 0 0 1-1.06-1.06 6 6 0 0 0 0-8.486.75.75 0 0 1 0-1.06ZM9.879 8.818a.75.75 0 0 1 0 1.06 3 3 0 0 0 0 4.243.75.75 0 1 1-1.061 1.061 4.5 4.5 0 0 1 0-6.364.75.75 0 0 1 1.06 0Zm4.242 0a.75.75 0 0 1 1.061 0 4.5 4.5 0 0 1 0 6.364.75.75 0 0 1-1.06-1.06 3 3 0 0 0 0-4.243.75.75 0 0 1 0-1.061ZM10.875 12a1.125 1.125 0 1 1 2.25 0 1.125 1.125 0 0 1-2.25 0Z" clip-rule="evenodd" />
</svg>
<span>Share (Zero Hop Advert)</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">
@@ -87,6 +95,15 @@ export default {
copyPublicKey(contact) { copyPublicKey(contact) {
Utils.copyToClipboard(Utils.bytesToHex(contact.publicKey)); Utils.copyToClipboard(Utils.bytesToHex(contact.publicKey));
}, },
async shareContact(contact) {
try {
await Connection.shareContact(contact.publicKey);
alert("Contact has been adverted!");
} catch(e) {
console.log(e);
alert("Failed to share this contact!");
}
},
async onResetPath(contact) { async onResetPath(contact) {
// confirm user wants to reset path // confirm user wants to reset path

View File

@@ -191,6 +191,10 @@ class Connection {
await GlobalState.connection.sendCommandRemoveContact(publicKey); await GlobalState.connection.sendCommandRemoveContact(publicKey);
} }
static async shareContact(publicKey) {
await GlobalState.connection.shareContact(publicKey);
}
static async sendMessage(publicKey, text) { static async sendMessage(publicKey, text) {
// send message // send message