fix spot market change
This commit is contained in:
parent
28c0fed1c7
commit
430cd939c4
|
@ -17,13 +17,6 @@ const rehydrateStore = async () => {
|
||||||
const HydrateStore = () => {
|
const HydrateStore = () => {
|
||||||
const actions = mangoStore((s) => s.actions)
|
const actions = mangoStore((s) => s.actions)
|
||||||
const mangoAccount = mangoStore((s) => s.mangoAccount.current)
|
const mangoAccount = mangoStore((s) => s.mangoAccount.current)
|
||||||
const serumMarkets = mangoStore((s) => s.serumMarkets)
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (serumMarkets.length) {
|
|
||||||
actions.fetchSerumMarketPrices()
|
|
||||||
}
|
|
||||||
}, [actions, serumMarkets])
|
|
||||||
|
|
||||||
useInterval(() => {
|
useInterval(() => {
|
||||||
rehydrateStore()
|
rehydrateStore()
|
||||||
|
|
|
@ -11,6 +11,7 @@ import ContentBox from '../shared/ContentBox'
|
||||||
import Change from '../shared/Change'
|
import Change from '../shared/Change'
|
||||||
import MarketLogos from '@components/trade/MarketLogos'
|
import MarketLogos from '@components/trade/MarketLogos'
|
||||||
import dynamic from 'next/dynamic'
|
import dynamic from 'next/dynamic'
|
||||||
|
import SheenLoader from '@components/shared/SheenLoader'
|
||||||
const SimpleAreaChart = dynamic(
|
const SimpleAreaChart = dynamic(
|
||||||
() => import('@components/shared/SimpleAreaChart'),
|
() => import('@components/shared/SimpleAreaChart'),
|
||||||
{ ssr: false }
|
{ ssr: false }
|
||||||
|
@ -63,7 +64,7 @@ const SpotMarketsTable = () => {
|
||||||
chartData[0].value) /
|
chartData[0].value) /
|
||||||
chartData[0].value) *
|
chartData[0].value) *
|
||||||
100
|
100
|
||||||
: 0
|
: 'unavailable'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr key={market.publicKey.toString()}>
|
<tr key={market.publicKey.toString()}>
|
||||||
|
@ -103,8 +104,14 @@ const SpotMarketsTable = () => {
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div className="flex flex-col items-end">
|
<div className="flex flex-col items-end">
|
||||||
{change ? (
|
{change !== 'unavailable' ? (
|
||||||
<Change change={change} />
|
loadingSerumMarketPrices ? (
|
||||||
|
<SheenLoader>
|
||||||
|
<div className="h-5 w-12 rounded bg-th-bkg-2" />
|
||||||
|
</SheenLoader>
|
||||||
|
) : (
|
||||||
|
<Change change={change} />
|
||||||
|
)
|
||||||
) : (
|
) : (
|
||||||
<p className="text-th-fgd-4">{t('unavailable')}</p>
|
<p className="text-th-fgd-4">{t('unavailable')}</p>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -136,6 +136,14 @@ const AdvancedMarketHeader = () => {
|
||||||
const { t } = useTranslation(['common', 'trade'])
|
const { t } = useTranslation(['common', 'trade'])
|
||||||
const selectedMarket = mangoStore((s) => s.selectedMarket.current)
|
const selectedMarket = mangoStore((s) => s.selectedMarket.current)
|
||||||
const serumMarketPrices = mangoStore((s) => s.serumMarketPrices.data)
|
const serumMarketPrices = mangoStore((s) => s.serumMarketPrices.data)
|
||||||
|
const actions = mangoStore((s) => s.actions)
|
||||||
|
const serumMarkets = mangoStore((s) => s.serumMarkets)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (serumMarkets.length) {
|
||||||
|
actions.fetchSerumMarketPrices()
|
||||||
|
}
|
||||||
|
}, [actions, serumMarkets])
|
||||||
|
|
||||||
const marketPrices = useMemo(() => {
|
const marketPrices = useMemo(() => {
|
||||||
if (selectedMarket instanceof Serum3Market) {
|
if (selectedMarket instanceof Serum3Market) {
|
||||||
|
@ -147,7 +155,7 @@ const AdvancedMarketHeader = () => {
|
||||||
return prices
|
return prices
|
||||||
}
|
}
|
||||||
// need to handle perp
|
// need to handle perp
|
||||||
}, [selectedMarket])
|
}, [selectedMarket, serumMarketPrices])
|
||||||
|
|
||||||
const change = useMemo(() => {
|
const change = useMemo(() => {
|
||||||
if (marketPrices) {
|
if (marketPrices) {
|
||||||
|
|
Loading…
Reference in New Issue