From 62eeab06f541f7cdeb6098a7e13e5111d416145a Mon Sep 17 00:00:00 2001 From: Jared Vu Date: Fri, 6 Oct 2023 14:12:40 -0700 Subject: [PATCH] Fix marketDetails stringKey, do not update state with markets not tracked by Abacus (#61) --- src/lib/abacus/stateNotification.ts | 13 ++++++++----- src/views/MarketDetails.tsx | 6 ++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/lib/abacus/stateNotification.ts b/src/lib/abacus/stateNotification.ts index 6f9d92e..fa2b9e9 100644 --- a/src/lib/abacus/stateNotification.ts +++ b/src/lib/abacus/stateNotification.ts @@ -35,6 +35,7 @@ import { setAssets } from '@/state/assets'; import { setConfigs } from '@/state/configs'; import { setInputs } from '@/state/inputs'; import { setHistoricalFundings, setLiveTrades, setMarkets, setOrderbook } from '@/state/perpetuals'; +import { isTruthy } from '../isTruthy'; class AbacusStateNotifier implements AbacusStateNotificationProtocol { private store: RootStore | undefined; @@ -84,7 +85,7 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol { dispatch(setBalances(balances)); } if (updatedState.account?.stakingBalances) { - const stakingBalances: Record = {} + const stakingBalances: Record = {}; for (const { k, v } of updatedState.account.stakingBalances.toArray()) { stakingBalances[k] = v; } @@ -108,10 +109,12 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol { dispatch( setMarkets({ markets: Object.fromEntries( - (marketIds || updatedState.marketIds()?.toArray() || []).map((marketId: string) => { - const marketData = updatedState.market(marketId); - return [marketId, marketData]; - }) + (marketIds || updatedState.marketIds()?.toArray() || []) + .map((marketId: string) => { + const marketData = updatedState.market(marketId); + return [marketId, marketData]; + }) + .filter(isTruthy) ) as Record, update: !!marketIds, }) diff --git a/src/views/MarketDetails.tsx b/src/views/MarketDetails.tsx index 3296830..d1b0a18 100644 --- a/src/views/MarketDetails.tsx +++ b/src/views/MarketDetails.tsx @@ -139,11 +139,9 @@ export const MarketDetails: React.FC = () => { - {primaryDescriptionKey && ( -

{stringGetter({ key: STRING_KEYS[primaryDescriptionKey as StringKey] })}

- )} + {primaryDescriptionKey &&

{stringGetter({ key: `APP.${primaryDescriptionKey}` })}

} {secondaryDescriptionKey && ( -

{stringGetter({ key: STRING_KEYS[secondaryDescriptionKey as StringKey] })}

+

{stringGetter({ key: `APP.${secondaryDescriptionKey}` })}

)}