add export contact command

This commit is contained in:
liamcottle 2025-02-15 20:45:07 +13:00
parent cf4e1ccd83
commit 12276302a7
3 changed files with 20 additions and 0 deletions

View file

@ -92,6 +92,9 @@
<button @click="sendChannelTextMessage" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
SendChannelTxtMessage
</button>
<button @click="exportContact(null)" class="border border-gray-500 px-2 bg-gray-100 hover:bg-gray-200 rounded">
ExportContact
</button>
</div>
</div>
@ -119,6 +122,7 @@
<div @click="sendMessage(contact)" class="hover:underline cursor-pointer">Message</div>
<div @click="setPath(contact)" class="hover:underline cursor-pointer">Set Path</div>
<div @click="shareContact(contact)" class="hover:underline cursor-pointer">Share (Zero Hop)</div>
<div @click="exportContact(contact)" class="hover:underline cursor-pointer">Export</div>
<div @click="resetPath(contact)" class="hover:underline cursor-pointer">Reset Path</div>
<div @click="removeContact(contact)" class="hover:underline cursor-pointer">Forget</div>
</div>
@ -341,6 +345,9 @@
async shareContact(contact) {
await this.connection.sendCommandShareContact(contact.publicKey);
},
async exportContact(contact) {
await this.connection.sendCommandExportContact(contact?.publicKey);
},
async setPath(contact) {
const newOutPath = [

View file

@ -154,6 +154,17 @@ class Connection extends EventEmitter {
await this.sendToRadioFrame(data.toBytes());
}
// provide a public key to export that contact
// not providing a public key will export local identity as a contact instead
async sendCommandExportContact(pubKey = null) {
const data = new BufferWriter();
data.writeByte(Constants.CommandCodes.ExportContact);
if(pubKey){
data.writeBytes(pubKey); // 32 bytes
}
await this.sendToRadioFrame(data.toBytes());
}
onFrameReceived(frame) {
// emit received frame

View file

@ -28,6 +28,7 @@ class Constants {
SetAdvertLatLon: 14,
RemoveContact: 15,
ShareContact: 16,
ExportContact: 17,
}
static ResponseCodes = {
@ -42,6 +43,7 @@ class Constants {
ChannelMsgRecv: 8,
CurrTime: 9,
NoMoreMessages: 10,
ExportContact: 11,
}
static PushCodes = {