From 9e3f4b59b4f3121dc3ed5fa73fcb17005ac76662 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 27 May 2024 18:33:23 +0900 Subject: [PATCH 1/2] fix: remove unused txformsmodal --- .../dashboard/modal/TxFormsModal.tsx | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 app/client/src/components/dashboard/modal/TxFormsModal.tsx diff --git a/app/client/src/components/dashboard/modal/TxFormsModal.tsx b/app/client/src/components/dashboard/modal/TxFormsModal.tsx deleted file mode 100644 index 49208e9..0000000 --- a/app/client/src/components/dashboard/modal/TxFormsModal.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { useAuth } from "../../../contexts/AuthContext"; -import { Text } from "../../commons"; - -const TxFormsModal = () => { - const { txId, expectedTick, txStatus, tick } = useAuth(); - - return ( -
- {txStatus.includes('broadcast for tick') && -
- Sending... -
- transactionId: {txId}
- currentTick: {tick}
- expectedTick: {expectedTick} -
- } - {txStatus.includes('no command pending') && - -
- Checked Blue - -
- - Success - -
-
- } -
- ); -}; - -export default TxFormsModal; From 1783c55c43752b73315ba4f96c4b3cddb1e95b34 Mon Sep 17 00:00:00 2001 From: Denis Date: Mon, 27 May 2024 18:33:34 +0900 Subject: [PATCH 2/2] update reconnecting feature --- .../controllers/liveSocketController.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/server/controllers/liveSocketController.js b/app/server/controllers/liveSocketController.js index 7cc1430..e7d7069 100644 --- a/app/server/controllers/liveSocketController.js +++ b/app/server/controllers/liveSocketController.js @@ -2,17 +2,34 @@ const socketManager = require('../managers/socketManager'); const stateManager = require('../managers/stateManager'); const { setRemoteSubshash } = require('../managers/stateManager'); const wasmManager = require('../managers/wasmManager'); -const { splitAtFirstSpace } = require('../utils/helpers'); +const { splitAtFirstSpace, socketSync } = require('../utils/helpers'); module.exports = function (liveSocketURL) { let liveSocket; + let reconnectingStatus = false; const connect = () => { liveSocket = socketManager.initLiveSocket(liveSocketURL); - liveSocket.on('open', (client) => { - console.log(client) + liveSocket.on('open', () => { console.log("Connected to the live socket"); + const init = async () => { + const userState = stateManager.getUserState(); + let realPassword = userState.password; + listResult = await wasmManager.ccall({ command: `list ${realPassword}`, flag: 'login' }); + const addresses = listResult.value.display.addresses; + await socketSync(addresses[0]); + const hexResult = await wasmManager.ccall({ command: `logintx ${realPassword}`, flag: 'logintx' }); + await socketSync(hexResult.value.display); + reconnectingStatus = false; + for (idx = 1; idx < addresses.length; idx++) { + if (addresses[idx] && addresses[idx] != "") { + liveSocket.send(addresses[idx]); + } + } + } + if (reconnectingStatus) + init(); }); liveSocket.on('error', (error) => { @@ -46,6 +63,7 @@ module.exports = function (liveSocketURL) { liveSocket.on('close', () => { console.log("Disconnected from the server. Attempting to reconnect..."); + reconnectingStatus = true; setTimeout(connect, 1000); // Attempt to reconnect after 1 seconds }); };