implement basic send message

This commit is contained in:
liamcottle
2025-02-13 01:35:38 +13:00
parent 24fec964de
commit 928bd45d81
2 changed files with 17 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ import Page from "./Page.vue";
import GlobalState from "../../js/GlobalState.js";
import ConnectButtons from "../connect/ConnectButtons.vue";
import ContactsList from "../contacts/ContactsList.vue";
import Connection from "../../js/Connection.js";
export default {
name: 'MainPage',
@@ -33,8 +34,17 @@ export default {
Header,
},
methods: {
onContactClick(contact) {
// todo
async onContactClick(contact) {
// ask user for message
const message = prompt("Enter message to send");
if(!message){
return;
}
// send message
await Connection.sendMessage(contact.publicKey, message);
},
},
computed: {

View File

@@ -73,6 +73,11 @@ class Connection {
await GlobalState.connection.sendCommandRemoveContact(publicKey);
}
static async sendMessage(publicKey, message) {
await GlobalState.connection.sendTextMessage(publicKey, message);
// todo handle acks
}
}
export default Connection;