From 3bf6ace4bf662bfcb9952e5049b6a2dda89b1ab2 Mon Sep 17 00:00:00 2001 From: tjs Date: Mon, 26 Dec 2022 16:04:15 -0500 Subject: [PATCH] fetch open orders after mango account websocket update --- components/MangoProvider.tsx | 8 ++++---- hooks/useUnsettledSpotBalances.ts | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/MangoProvider.tsx b/components/MangoProvider.tsx index 3ec0e156..49f12b51 100644 --- a/components/MangoProvider.tsx +++ b/components/MangoProvider.tsx @@ -6,18 +6,19 @@ import { MangoAccount } from '@blockworks-foundation/mango-v4' import useMangoAccount from 'hooks/useMangoAccount' import useInterval from './shared/useInterval' +const set = mangoStore.getState().set +const actions = mangoStore.getState().actions + const HydrateStore = () => { const router = useRouter() const { name: marketName } = router.query const { mangoAccount } = useMangoAccount() const fetchData = useCallback(async () => { - const actions = mangoStore.getState().actions await actions.fetchGroup() }, []) useEffect(() => { - const set = mangoStore.getState().set if (marketName && typeof marketName === 'string') { set((s) => { s.selectedMarket.name = marketName @@ -34,7 +35,6 @@ const HydrateStore = () => { useEffect(() => { const connection = mangoStore.getState().connection const client = mangoStore.getState().client - const set = mangoStore.getState().set if (!mangoAccount) return @@ -65,7 +65,7 @@ const HydrateStore = () => { decodedMangoAccount ) await newMangoAccount.reloadAccountData(client) - + actions.fetchOpenOrders() // newMangoAccount.spotOpenOrdersAccounts = // mangoAccount.spotOpenOrdersAccounts // newMangoAccount.advancedOrders = mangoAccount.advancedOrders diff --git a/hooks/useUnsettledSpotBalances.ts b/hooks/useUnsettledSpotBalances.ts index 6f68c717..0175380a 100644 --- a/hooks/useUnsettledSpotBalances.ts +++ b/hooks/useUnsettledSpotBalances.ts @@ -9,7 +9,6 @@ export function useUnsettledSpotBalances() { const { mangoAccount } = useMangoAccount() const openOrdersAccounts = mangoStore.getState().mangoAccount.openOrderAccounts - console.log('openOrdersAccount', openOrdersAccounts) const unsettledSpotBalances = useMemo(() => { if (!group || !mangoAccount || !openOrdersAccounts) return {}