From 1f938be3628423f2e8ec5ab912a6c41401fea85b Mon Sep 17 00:00:00 2001 From: Kobe Date: Mon, 16 Dec 2024 10:17:28 +0100 Subject: [PATCH] fix: fetch priority fee & bundle tip --- .../src/context/TradeProvider.tsx | 63 ++++++++----------- 1 file changed, 27 insertions(+), 36 deletions(-) diff --git a/apps/marginfi-v2-trading/src/context/TradeProvider.tsx b/apps/marginfi-v2-trading/src/context/TradeProvider.tsx index d5c3f3d5cb..cb35947122 100644 --- a/apps/marginfi-v2-trading/src/context/TradeProvider.tsx +++ b/apps/marginfi-v2-trading/src/context/TradeProvider.tsx @@ -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) {