Skip to content

Commit

Permalink
fix: fetch priority fee & bundle tip
Browse files Browse the repository at this point in the history
  • Loading branch information
k0beLeenders committed Dec 16, 2024
1 parent b77ba8a commit 1f938be
Showing 1 changed file with 27 additions and 36 deletions.
63 changes: 27 additions & 36 deletions apps/marginfi-v2-trading/src/context/TradeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,43 +82,34 @@ export const TradePovider: React.FC<{
}
}, [router.asPath, wallet, connected, isLoggedIn]);

// React.useEffect(() => {
// const fetchData = () => {
// setIsRefreshingStore(true);
// fetchPriorityFee(connection);
// fetchTradeState({
// connection,
// wallet,
// });
// };

// if (debounceId.current) {
// clearTimeout(debounceId.current);
// }
React.useEffect(() => {
const fetchData = () => {
fetchPriorityFee(connection);
};

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

// debounceId.current = setTimeout(() => {
// fetchData();

// const id = setInterval(() => {
// setIsRefreshingStore(true);
// fetchTradeState({});
// fetchPriorityFee(connection);
// }, 50_000);

// return () => {
// clearInterval(id);
// clearTimeout(debounceId.current!);
// };
// }, 1000);

// return () => {
// if (debounceId.current) {
// clearTimeout(debounceId.current);
// }
// };
// }, [wallet, isOverride]); // eslint-disable-line react-hooks/exhaustive-deps
// ^ crucial to omit both `connection` and `fetchMrgnlendState` from the dependency array
// TODO: fix...
debounceId.current = setTimeout(() => {
fetchData();

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

return () => {
clearInterval(id);
clearTimeout(debounceId.current!);
};
}, 1000);

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

// React.useEffect(() => {
// if (!connected && resetUserData) {
Expand Down

0 comments on commit 1f938be

Please sign in to comment.