Skip to content

Commit

Permalink
Merge pull request #2189 from decentdao/fetch-token-balances-once
Browse files Browse the repository at this point in the history
Don't refetch token balances every 20 seconds
  • Loading branch information
adamgall authored Jul 31, 2024
2 parents 49301f5 + 456c8ce commit 01c3086
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 01c3086

Please sign in to comment.