Skip to content

Commit

Permalink
Don't refetch token balances every x (20) seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgall committed Jul 30, 2024
1 parent 8a78eaf commit 456c8ce
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/hooks/DAO/loaders/useDecentTreasury.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import useBalancesAPI from '../../../providers/App/hooks/useBalancesAPI';
import { useSafeAPI } from '../../../providers/App/hooks/useSafeAPI';
import { TreasuryAction } from '../../../providers/App/treasury/action';
import { useNetworkConfig } from '../../../providers/NetworkConfig/NetworkConfigProvider';
import { useUpdateTimer } from '../../utils/useUpdateTimer';

export const useDecentTreasury = () => {
// tracks the current valid DAO address / chain; helps prevent unnecessary calls
Expand All @@ -19,8 +18,6 @@ export const useDecentTreasury = () => {

const { chain } = useNetworkConfig();

const { setMethodOnInterval, clearIntervals } = useUpdateTimer(daoAddress);

const loadTreasury = useCallback(async () => {
if (!daoAddress || !safeAPI) {
return;
Expand Down Expand Up @@ -58,13 +55,12 @@ export const useDecentTreasury = () => {
useEffect(() => {
if (daoAddress && chain.id + daoAddress !== loadKey.current) {
loadKey.current = chain.id + daoAddress;
setMethodOnInterval(loadTreasury);
loadTreasury();
}
if (!daoAddress) {
loadKey.current = null;
clearIntervals();
}
}, [chain, daoAddress, loadTreasury, setMethodOnInterval, clearIntervals]);
}, [chain, daoAddress, loadTreasury]);

return;
};

0 comments on commit 456c8ce

Please sign in to comment.