Skip to content

Commit

Permalink
fix: improved periodic fetching for fee tip
Browse files Browse the repository at this point in the history
  • Loading branch information
k0beLeenders committed Dec 22, 2024
1 parent e926d9b commit 1a581ba
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions apps/marginfi-v2-trading/src/context/TradeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,31 +104,23 @@ export const TradePovider: React.FC<{
}, [router.asPath, wallet, connected, isLoggedIn]);

React.useEffect(() => {
const fetchData = () => {
const initializeAndFetch = () => {
fetchPriorityFee(connection);
};

if (debounceId.current) {
clearTimeout(debounceId.current);
}

debounceId.current = setTimeout(() => {
fetchData();
debounceId.current = setTimeout(initializeAndFetch, 1000);

const id = setInterval(() => {
fetchPriorityFee(connection);
}, 50_000);

return () => {
clearInterval(id);
clearTimeout(debounceId.current!);
};
}, 1000);
const intervalId = setInterval(initializeAndFetch, 60_000);

return () => {
if (debounceId.current) {
clearTimeout(debounceId.current);
}
clearInterval(intervalId);
};
}, []); // eslint-disable-line react-hooks/exhaustive-deps

Expand Down

0 comments on commit 1a581ba

Please sign in to comment.