From c5f332e81ccdf05279646861a831e16ba8559fcb Mon Sep 17 00:00:00 2001 From: Linguists <95207870+linguists@users.noreply.github.com> Date: Sat, 6 May 2023 12:26:31 +0800 Subject: [PATCH 1/2] fix: near balance refresh --- src/LiNEAR.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LiNEAR.jsx b/src/LiNEAR.jsx index 4f72d14..3812962 100644 --- a/src/LiNEAR.jsx +++ b/src/LiNEAR.jsx @@ -131,7 +131,7 @@ function getLinearBalance(accountId, subscribe) { const nearBalance = state.nearBalance; // Initial fetch of account NEAR balance if (accountId && !isValid(nearBalance)) { - getNearBalance(accountId); + getNearBalance(accountId, () => {}); } const linearBalance = accountId ? getLinearBalance(accountId) : "-"; From e61840fb519665d71c8081aa9310e2ce153bd243 Mon Sep 17 00:00:00 2001 From: Linguists <95207870+linguists@users.noreply.github.com> Date: Sat, 6 May 2023 12:31:21 +0800 Subject: [PATCH 2/2] fix: update balance without cache --- src/LiNEAR.jsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/LiNEAR.jsx b/src/LiNEAR.jsx index 3812962..43d50f9 100644 --- a/src/LiNEAR.jsx +++ b/src/LiNEAR.jsx @@ -104,13 +104,9 @@ function getNearBalance(accountId, onInvalidate) { }, }), }; - if (onInvalidate) { - asyncFetch(config.nodeUrl, options).then((account) => - updateNearBalance(account, onInvalidate) - ); - } else { - updateNearBalance(fetch(config.nodeUrl, options)); - } + asyncFetch(config.nodeUrl, options).then((account) => + updateNearBalance(account, onInvalidate) + ); } function getLinearBalance(accountId, subscribe) { @@ -131,7 +127,7 @@ function getLinearBalance(accountId, subscribe) { const nearBalance = state.nearBalance; // Initial fetch of account NEAR balance if (accountId && !isValid(nearBalance)) { - getNearBalance(accountId, () => {}); + getNearBalance(accountId); } const linearBalance = accountId ? getLinearBalance(accountId) : "-";