diff --git a/web/cashtab/src/components/Common/Ticker.js b/web/cashtab/src/components/Common/Ticker.js --- a/web/cashtab/src/components/Common/Ticker.js +++ b/web/cashtab/src/components/Common/Ticker.js @@ -26,7 +26,7 @@ tokenDbUrl: 'https://tokendb.kingbch.com', txHistoryCount: 10, xecApiBatchSize: 20, - walletRefreshInterval: 1000, // 1000 = 1s + walletRefreshInterval: 30000, // 1000 = 1s defaultSettings: { fiatCurrency: 'usd', sendModal: false }, notificationDurationShort: 3, notificationDurationLong: 5, diff --git a/web/cashtab/src/hooks/useWallet.js b/web/cashtab/src/hooks/useWallet.js --- a/web/cashtab/src/hooks/useWallet.js +++ b/web/cashtab/src/hooks/useWallet.js @@ -33,7 +33,9 @@ const chronik = new ChronikClient(currency.chronikUrl); const useWallet = () => { - const [walletRefreshInterval] = useState(currency.walletRefreshInterval); + const [walletRefreshInterval, setWalletRefreshInterval] = useState( + currency.walletRefreshInterval, + ); const [wallet, setWallet] = useState(false); const [chronikWebsocket, setChronikWebsocket] = useState(null); const [contactList, setContactList] = useState(false); @@ -211,6 +213,12 @@ const update = async ({ wallet }) => { //console.log(`tick()`); //console.time("update"); + + // Check if walletRefreshInterval is set to 10, i.e. this was called by websocket tx detection + // If walletRefreshInterval is 10, set it back to the usual refresh rate + if (walletRefreshInterval === 10) { + setWalletRefreshInterval(currency.walletRefreshInterval); + } try { if (!wallet) { return; @@ -248,7 +256,6 @@ utxos, previousUtxos, ); - // If the utxo set has not changed, if (!utxosHaveChanged) { // remove api error here; otherwise it will remain if recovering from a rate @@ -940,6 +947,10 @@ if (type !== 'AddedToMempool') { return; } + // If you see a tx from your subscribed addresses added to the mempool, then the wallet utxo set has changed + // Update it + setWalletRefreshInterval(10); + // get txid info const txid = msg.txid; const txDetails = await chronik.tx(txid);