fix data issues when switching markets (#31)

This commit is contained in:
Maximilian Schneider 2021-06-12 22:03:05 -04:00 committed by GitHub
parent 3b66cf9090
commit 3dbbe87ded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 2 deletions

View File

@ -20,6 +20,8 @@ const MarketHeader = () => {
const volume = ohlcv ? ohlcv.v[0] : '--'
const fetchOhlcv = useCallback(async () => {
if (!selectedMarketName) return
// calculate from and to date (0:00UTC to 23:59:59UTC)
const date = new Date()
const utcFrom = new Date(
@ -118,7 +120,7 @@ const MarketHeader = () => {
<div className="pr-4 sm:pr-0 sm:w-24">
<div className="mb-0.5 text-th-fgd-4 text-xs">24hr Vol</div>
<div className={`font-semibold`}>
{ohlcv && !loading && volume ? (
{ohlcv && !loading ? (
volume !== '--' ? (
<>
{volume.toFixed(2)}

View File

@ -13,6 +13,8 @@ export default function PublicTrades() {
const [trades, setTrades] = useState([])
const fetchTradesForChart = useCallback(async () => {
if (!marketAddress) return
const newTrades = await ChartApi.getRecentTrades(marketAddress)
if (!newTrades) return null
if (newTrades.length && trades.length === 0) {

View File

@ -16,6 +16,7 @@ export default function useOraclePrice() {
const fetchOraclePrice = useCallback(() => {
if (selectedMangoGroup) {
setOraclePrice(null)
const marketIndex = getMarketIndex(marketAddress)
selectedMangoGroup.getPrices(connection).then((prices) => {
const oraclePriceForMarket = prices[marketIndex]

View File

@ -8,7 +8,7 @@
"build": "next build",
"start": "next start",
"type-check": "tsc --pretty --noEmit",
"format": "prettier --check .",
"format": "prettier --write .",
"lint": "eslint . --ext ts --ext tsx --ext js --quiet",
"test": "jest",
"test-all": "yarn lint && yarn type-check && yarn test"