fix call to swap history api
This commit is contained in:
parent
ea0d1ce4d4
commit
aae95b6b4a
|
@ -1,4 +1,4 @@
|
|||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import mangoStore from '@store/mangoStore'
|
||||
import TabButtons from '../shared/TabButtons'
|
||||
import TokenList from '../TokenList'
|
||||
|
@ -6,7 +6,6 @@ import SwapHistoryTable from '../swap/SwapHistoryTable'
|
|||
import ActivityFeed from './ActivityFeed'
|
||||
import UnsettledTrades from '@components/trade/UnsettledTrades'
|
||||
import { useUnsettledSpotBalances } from 'hooks/useUnsettledSpotBalances'
|
||||
import useMangoAccount from 'hooks/useMangoAccount'
|
||||
import { useViewport } from 'hooks/useViewport'
|
||||
import { breakpoints } from 'utils/theme'
|
||||
import useUnsettledPerpPositions from 'hooks/useUnsettledPerpPositions'
|
||||
|
@ -20,8 +19,6 @@ const TABS = [
|
|||
|
||||
const AccountTabs = () => {
|
||||
const [activeTab, setActiveTab] = useState('balances')
|
||||
const actions = mangoStore((s) => s.actions)
|
||||
const { mangoAccount } = useMangoAccount()
|
||||
const { width } = useViewport()
|
||||
const isMobile = width ? width < breakpoints.md : false
|
||||
|
||||
|
@ -29,12 +26,6 @@ const AccountTabs = () => {
|
|||
return TABS.map((t) => [t, 0])
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (mangoAccount) {
|
||||
actions.fetchSwapHistory(mangoAccount.publicKey.toString())
|
||||
}
|
||||
}, [actions, mangoAccount])
|
||||
|
||||
return (
|
||||
<>
|
||||
<TabButtons
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Fragment, useState } from 'react'
|
||||
import { Fragment, useEffect, useState } from 'react'
|
||||
import {
|
||||
ArrowRightIcon,
|
||||
ChevronDownIcon,
|
||||
|
@ -13,7 +13,7 @@ import { useViewport } from '../../hooks/useViewport'
|
|||
import { IconButton } from '../shared/Button'
|
||||
import { Transition } from '@headlessui/react'
|
||||
import SheenLoader from '../shared/SheenLoader'
|
||||
import { SwapHistoryItem } from '@store/mangoStore'
|
||||
import mangoStore, { SwapHistoryItem } from '@store/mangoStore'
|
||||
import {
|
||||
countLeadingZeros,
|
||||
formatFixedDecimals,
|
||||
|
@ -27,6 +27,7 @@ import useJupiterMints from 'hooks/useJupiterMints'
|
|||
import { Table, Td, Th, TrBody, TrHead } from '@components/shared/TableElements'
|
||||
import { useWallet } from '@solana/wallet-adapter-react'
|
||||
import { EXPLORERS } from '@components/settings/PreferredExplorerSettings'
|
||||
import useMangoAccount from 'hooks/useMangoAccount'
|
||||
|
||||
const SwapHistoryTable = ({
|
||||
swapHistory,
|
||||
|
@ -39,6 +40,8 @@ const SwapHistoryTable = ({
|
|||
const { connected } = useWallet()
|
||||
const { mangoTokens } = useJupiterMints()
|
||||
const [showSwapDetails, setSwapDetails] = useState('')
|
||||
const actions = mangoStore((s) => s.actions)
|
||||
const { mangoAccount } = useMangoAccount()
|
||||
const { width } = useViewport()
|
||||
const showTableView = width ? width > breakpoints.md : false
|
||||
const [preferredExplorer] = useLocalStorageState(
|
||||
|
@ -46,6 +49,12 @@ const SwapHistoryTable = ({
|
|||
EXPLORERS[0]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (mangoAccount) {
|
||||
actions.fetchSwapHistory(mangoAccount.publicKey.toString())
|
||||
}
|
||||
}, [actions, mangoAccount])
|
||||
|
||||
const handleShowSwapDetails = (signature: string) => {
|
||||
showSwapDetails ? setSwapDetails('') : setSwapDetails(signature)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import React, {
|
||||
Dispatch,
|
||||
SetStateAction,
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useState,
|
||||
|
@ -198,7 +199,7 @@ const SwapReviewRouteInfo = ({
|
|||
}
|
||||
}, [inputTokenInfo, outputTokenInfo])
|
||||
|
||||
const onSwap = async () => {
|
||||
const onSwap = useCallback(async () => {
|
||||
if (!selectedRoute) return
|
||||
try {
|
||||
const client = mangoStore.getState().client
|
||||
|
@ -246,6 +247,7 @@ const SwapReviewRouteInfo = ({
|
|||
noSound: true,
|
||||
})
|
||||
actions.fetchGroup()
|
||||
actions.fetchSwapHistory(mangoAccount.publicKey.toString())
|
||||
await actions.reloadMangoAccount()
|
||||
} catch (e: any) {
|
||||
console.error('onSwap error: ', e)
|
||||
|
@ -263,7 +265,7 @@ const SwapReviewRouteInfo = ({
|
|||
} finally {
|
||||
onClose()
|
||||
}
|
||||
}
|
||||
}, [amountIn, onClose, selectedRoute, soundSettings])
|
||||
|
||||
const [balance, borrowAmount] = useMemo(() => {
|
||||
const mangoAccount = mangoStore.getState().mangoAccount.current
|
||||
|
|
Loading…
Reference in New Issue