From 3573b0d4151c935c931eb86da6e34f3f15de564b Mon Sep 17 00:00:00 2001 From: AnisHADJARAB Date: Thu, 17 Oct 2024 12:31:12 +0000 Subject: [PATCH] fix double websocket and wait for websocket to open to send paring tx --- src/html/home.js | 5 +++-- src/index.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/html/home.js b/src/html/home.js index bc58957..7aab0ae 100644 --- a/src/html/home.js +++ b/src/html/home.js @@ -36,8 +36,8 @@ document.querySelectorAll('.tab').forEach(tab => { notifications.style.display = notifications?.style.display === 'none' ? 'block' : 'none' } -const service = await Services.getInstance() -service.setNotification() +// const service = await Services.getInstance() +// service.setNotification() window.toggleMenu = toggleMenu; window.openModal = openModal; @@ -73,6 +73,7 @@ docReady(function () { if (spAddress) { html5QrcodeScanner.clear(); + const service = await Services.getInstance() // Call the sendPairingTx function with the extracted sp_address await service.sendPairingTx(spAddress); } else { diff --git a/src/index.ts b/src/index.ts index f057c04..3ab6f7c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,7 +22,7 @@ document.addEventListener('DOMContentLoaded', async () => { const pairingAddress = urlParams.get('sp_address') if(pairingAddress) { - await services.sendPairingTx(pairingAddress) + setTimeout(async () => await services.sendPairingTx(pairingAddress), 1000) } } }, 500);