handle no open orders account

This commit is contained in:
Tyler Shipe 2021-04-13 20:14:38 -04:00
parent d495be6b32
commit 8b418dbe5f
1 changed files with 2 additions and 6 deletions

View File

@ -47,6 +47,7 @@ const useFills = () => {
const marketIndex = selectedMangoGroup.getMarketIndex(market) const marketIndex = selectedMangoGroup.getMarketIndex(market)
const openOrdersAccount = marginAccount.openOrdersAccounts[marketIndex] const openOrdersAccount = marginAccount.openOrdersAccounts[marketIndex]
if (!openOrdersAccount) return []
return fills return fills
.filter((fill) => fill.openOrders.equals(openOrdersAccount.publicKey)) .filter((fill) => fill.openOrders.equals(openOrdersAccount.publicKey))
.map((fill) => ({ ...fill, marketName })) .map((fill) => ({ ...fill, marketName }))
@ -97,12 +98,7 @@ export const useTradeHistory = () => {
}, 10000) }, 10000)
useEffect(() => { useEffect(() => {
if ( if (eventQueueFills && eventQueueFills.length > 0) {
eventQueueFills &&
tradeHistory &&
tradeHistory.length > 0 &&
eventQueueFills.length > 0
) {
const newFills = eventQueueFills.filter( const newFills = eventQueueFills.filter(
(fill) => (fill) =>
!tradeHistory.find((t) => t.orderId === fill.orderId.toString()) !tradeHistory.find((t) => t.orderId === fill.orderId.toString())