Add send message screen
This commit is contained in:
parent
51465902bd
commit
3330baefc1
@ -1,4 +1,4 @@
|
|||||||
import { createUserReturn, User, Process } from '../dist/pkg/sdk_client';
|
import { createUserReturn, User, Process, createNotificationTransactionReturn, parse_network_msg, outputs_list, parseNetworkMsgReturn, FaucetMessage, AnkFlag } from '../dist/pkg/sdk_client';
|
||||||
import IndexedDB from './database'
|
import IndexedDB from './database'
|
||||||
import { WebSocketClient } from './websockets';
|
import { WebSocketClient } from './websockets';
|
||||||
|
|
||||||
@ -7,6 +7,7 @@ class Services {
|
|||||||
private sdkClient: any;
|
private sdkClient: any;
|
||||||
private current_process: string | null = null;
|
private current_process: string | null = null;
|
||||||
private websocketConnection: WebSocketClient[] = [];
|
private websocketConnection: WebSocketClient[] = [];
|
||||||
|
private sp_address: string | null = null;
|
||||||
|
|
||||||
// Private constructor to prevent direct instantiation from outside
|
// Private constructor to prevent direct instantiation from outside
|
||||||
private constructor() {}
|
private constructor() {}
|
||||||
@ -58,6 +59,37 @@ class Services {
|
|||||||
await services.displayProcess();
|
await services.displayProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async displaySendMessage(): Promise<void> {
|
||||||
|
const services = await Services.getInstance();
|
||||||
|
await services.injectHtml('Messaging');
|
||||||
|
services.attachSubmitListener("form4nk", (event) => services.sendMessage(event));
|
||||||
|
const ourAddress = document.getElementById('our_address');
|
||||||
|
if (ourAddress) {
|
||||||
|
ourAddress.innerHTML = `<strong>Our Address:</strong> ${this.sp_address}`
|
||||||
|
}
|
||||||
|
// services.attachClickListener("displaysendmessage", services.displaySendMessage);
|
||||||
|
// await services.displayProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async sendMessage(event: Event): Promise<void> {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const spAddressElement = document.getElementById("sp_address") as HTMLInputElement;
|
||||||
|
const messageElement = document.getElementById("message") as HTMLInputElement;
|
||||||
|
|
||||||
|
if (!spAddressElement || !messageElement) {
|
||||||
|
console.error("One or more elements not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const recipientSpAddress = spAddressElement.value;
|
||||||
|
const message = messageElement.value;
|
||||||
|
const services = await Services.getInstance();
|
||||||
|
|
||||||
|
let notificationInfo = services.notify_address_for_message(recipientSpAddress, message);
|
||||||
|
console.log(notificationInfo);
|
||||||
|
}
|
||||||
|
|
||||||
public async createId(event: Event): Promise<void> {
|
public async createId(event: Event): Promise<void> {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user