add checkers for device 1 and 2 (waiting modal)

This commit is contained in:
NicolasCantu 2024-12-26 16:13:02 +01:00
parent 267bb06260
commit 77e8c802b8
2 changed files with 20 additions and 0 deletions

View File

@ -13,6 +13,7 @@ export const U32_MAX = 4294967295;
const storageUrl = `https://demo.4nkweb.com/storage`;
const BOOTSTRAPURL = [`https://demo.4nkweb.com/ws/`];
export default class Services {
private static initializing: Promise<Services> | null = null;
private static instance: Services;
@ -290,6 +291,13 @@ export default class Services {
const apiReturn = this.sdkClient.parse_cipher(message);
console.log('🚀 ~ Services ~ parseCipher ~ apiReturn:', apiReturn);
await this.handleApiReturn(apiReturn);
// Device 1 wait Device 2
const waitingModal = document.getElementById('waiting-modal');
if (waitingModal) {
this.device2Ready = true;
}
} catch (e) {
console.error(`Parsed cipher with error: ${e}`);
}
@ -666,4 +674,13 @@ export default class Services {
async importJSON(content: any): Promise<void> {
return Promise.resolve();
}
// Device 1 wait Device 2
public device1: boolean = false;
public device2Ready: boolean = false;
public resetState() {
this.device1 = false;
this.device2Ready = false;
}
}

View File

@ -161,6 +161,9 @@ async function onOkButtonClick() {
export async function prepareAndSendPairingTx(secondDeviceAddress: string) {
const service = await Services.getInstance();
// Device 1 wait Device 2
service.device1 = true;
const sharedSecret = await service.getSecretForAddress(secondDeviceAddress);
if (!sharedSecret) {
const member = {