diff --git a/src/App.tsx b/src/App.tsx index 86c529dc..e6f15c76 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -457,27 +457,27 @@ const WalletInfoAutoReload = ({ walletFileName }: { walletFileName: WalletFileNa const { rescanInfo: currentRescanInfo } = useRescanStatus() const { refetch: refetchWalletBalance, utxosHashHex } = useJamWalletInfoContext() const [previousRescanning, setPreviousRescanning] = useState(currentRescanInfo.rescanning) + const [rescanningFinished, setRescanningFinished] = useState(false) + + if (previousRescanning !== currentRescanInfo.rescanning) { + setPreviousRescanning(currentRescanInfo.rescanning) + setRescanningFinished(previousRescanning === true && currentRescanInfo.rescanning === false) + } - // eslint-disable-next-line @tanstack/query/exhaustive-deps useQuery({ queryKey: [ 'reload-wallet-after-rescan-or-utxo-change', walletFileName, - previousRescanning, - currentRescanInfo.rescanning, + refetchWalletBalance, utxosHashHex, + rescanningFinished, ], queryFn: async () => { - const rescanningFinished = previousRescanning === true && currentRescanInfo.rescanning === false - const delayBefore: Milliseconds = rescanningFinished ? RELOAD_WALLET_INFO_DELAY.AFTER_RESCAN : RELOAD_WALLET_INFO_DELAY.AFTER_UTXO_CHANGE console.info('Trigger refetch looking for funds after rescan or utxo changes with delay %d...', delayBefore) - - const result = await refetchWalletBalance({ delayBefore }) - setPreviousRescanning(currentRescanInfo.rescanning) - return result + return await refetchWalletBalance({ delayBefore }) }, })