From 4229dd672961a4b5b48ee5a628b044f1f6e3b534 Mon Sep 17 00:00:00 2001 From: Niko PLP Date: Fri, 13 Oct 2023 22:26:52 +0300 Subject: [PATCH] changed reconnection logic --- ng-app/src/store.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ng-app/src/store.ts b/ng-app/src/store.ts index 64114c6..ec50a93 100644 --- a/ng-app/src/store.ts +++ b/ng-app/src/store.ts @@ -37,11 +37,7 @@ export const online = derived(connections,($connections) => { else if ($connections[cnx].error=="ConnectionError" && !$connections[cnx].connecting && next_reconnect==null) { console.log("will try reconnect in 1 min"); next_reconnect = setTimeout(async ()=> { - next_reconnect = null; - if (get(active_session)) { - console.log("attempting to connect..."); - await reconnect(); - } + await reconnect(); },60000); } } @@ -84,6 +80,14 @@ const can_connect = derived([active_wallet, active_session], ([$s1, $s2]) => [ ); export const reconnect = async function() { + if (next_reconnect) { + clearTimeout(next_reconnect); + next_reconnect = null; + } + if (!get(active_session)) { + return; + } + console.log("attempting to connect..."); try { let client = get(wallets)[get(active_wallet).id].client; let info = await ng.client_info()