Skip to content

Commit

Permalink
avoid unnecessary refreshes on the wallet documents
Browse files Browse the repository at this point in the history
  • Loading branch information
maycon-mello committed Nov 2, 2023
1 parent ac1a486 commit 0af9eca
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/react-native/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export function _useWalletController() {
wallet.getAllDocuments().then(setDocuments);
}, [documents, wallet, firstFetch]);

const refetch = async ({fetchBalances} = {fetchBalances: true}) => {
const refetch = useCallback(async ({fetchBalances} = {fetchBalances: true}) => {
try {
const allDocs = await wallet.query({});
if (fetchBalances) {
Expand All @@ -147,14 +147,14 @@ export function _useWalletController() {
} catch (err) {
console.error(err);
}
}
}, [wallet, setDocuments]);

useEffect(() => {
if (!wallet) {
return;
}

const _refetch = debounce(refetch, 800);
const _refetch = debounce(refetch, 100);

setStatus(wallet.status);
setNetworkId(wallet.getNetworkId());
Expand Down

0 comments on commit 0af9eca

Please sign in to comment.