mirror of
https://github.com/aljazceru/meshcore-web.git
synced 2025-12-18 08:34:21 +01:00
implement basic send message
This commit is contained in:
@@ -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: {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user