From 9a5f69f0eb0e0fe0373da052f429a89766469cb9 Mon Sep 17 00:00:00 2001 From: zeppi Date: Fri, 4 Feb 2022 16:09:39 -0500 Subject: [PATCH] prevent errant wallet servers error --- ui/redux/actions/wallet.js | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ui/redux/actions/wallet.js b/ui/redux/actions/wallet.js index d834075ec..d0012f531 100644 --- a/ui/redux/actions/wallet.js +++ b/ui/redux/actions/wallet.js @@ -525,7 +525,7 @@ export function doSupportAbandonForClaim(claimId, claimType, keep, preview) { } export function doWalletReconnect() { - return (dispatch) => { + return (dispatch, getState) => { dispatch({ type: ACTIONS.WALLET_RESTART, }); @@ -533,16 +533,23 @@ export function doWalletReconnect() { // this basically returns null when it's done. :( // might be good to dispatch ACTIONS.WALLET_RESTARTED const walletTimeout = setTimeout(() => { - failed = true; - dispatch({ - type: ACTIONS.WALLET_RESTART_COMPLETED, - }); - dispatch( - doToast({ - message: __('Your servers were not available. Check your url and port, or switch back to defaults.'), - isError: true, - }) - ); + const state = getState(); + const { settings } = state; + const { daemonStatus } = settings || {}; + const { wallet } = daemonStatus || {}; + const availableServers = wallet.available_servers; + if (!availableServers) { + failed = true; + dispatch({ + type: ACTIONS.WALLET_RESTART_COMPLETED, + }); + dispatch( + doToast({ + message: __('Your servers were not available. Check your url and port, or switch back to defaults.'), + isError: true, + }) + ); + } }, FIFTEEN_SECONDS); Lbry.wallet_reconnect().then(() => { clearTimeout(walletTimeout);