fix loading
This commit is contained in:
parent
6664599bc2
commit
a9b3a2594c
|
@ -57,20 +57,21 @@ const HydrateStore = () => {
|
|||
useInterval(
|
||||
() => {
|
||||
actions.fetchGroup()
|
||||
actions.reloadMangoAccount()
|
||||
},
|
||||
(slowNetwork ? 60 : 30) * SECONDS,
|
||||
(slowNetwork ? 60 : 20) * SECONDS,
|
||||
)
|
||||
|
||||
// refetches open orders every 30 seconds
|
||||
// only the selected market's open orders are updated via websocket
|
||||
useInterval(
|
||||
() => {
|
||||
if (mangoAccountAddress) {
|
||||
actions.fetchOpenOrders()
|
||||
}
|
||||
},
|
||||
(slowNetwork ? 60 : 30) * SECONDS,
|
||||
)
|
||||
// useInterval(
|
||||
// () => {
|
||||
// if (mangoAccountAddress) {
|
||||
// actions.fetchOpenOrders()
|
||||
// }
|
||||
// },
|
||||
// (slowNetwork ? 60 : 30) * SECONDS,
|
||||
// )
|
||||
|
||||
// refetch trade history and activity feed when switching accounts
|
||||
useEffect(() => {
|
||||
|
@ -81,13 +82,13 @@ const HydrateStore = () => {
|
|||
}, [mangoAccountAddress])
|
||||
|
||||
// reload and parse market fills from the event queue
|
||||
useInterval(
|
||||
async () => {
|
||||
const actions = mangoStore.getState().actions
|
||||
actions.loadMarketFills()
|
||||
},
|
||||
(slowNetwork ? 60 : 20) * SECONDS,
|
||||
)
|
||||
// useInterval(
|
||||
// async () => {
|
||||
// const actions = mangoStore.getState().actions
|
||||
// actions.loadMarketFills()
|
||||
// },
|
||||
// (slowNetwork ? 60 : 20) * SECONDS,
|
||||
// )
|
||||
|
||||
// estimate the priority fee every 30 seconds
|
||||
useInterval(
|
||||
|
@ -133,7 +134,7 @@ const HydrateStore = () => {
|
|||
// don't fetch serum3OpenOrders if the slot is old
|
||||
if (context.slot > mangoStore.getState().mangoAccount.lastSlot) {
|
||||
if (newMangoAccount.serum3Active().length > 0) {
|
||||
await newMangoAccount.reloadSerum3OpenOrders(client)
|
||||
// await newMangoAccount.reloadSerum3OpenOrders(client)
|
||||
// check again that the slot is still the most recent after the reloading open orders
|
||||
if (context.slot > mangoStore.getState().mangoAccount.lastSlot) {
|
||||
set((s) => {
|
||||
|
@ -142,7 +143,7 @@ const HydrateStore = () => {
|
|||
})
|
||||
}
|
||||
}
|
||||
actions.fetchOpenOrders()
|
||||
// actions.fetchOpenOrders()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
@ -173,12 +174,12 @@ const ReadOnlyMangoAccount = () => {
|
|||
const client = mangoStore.getState().client
|
||||
const pk = new PublicKey(ma)
|
||||
const readOnlyMangoAccount = await client.getMangoAccount(pk)
|
||||
await readOnlyMangoAccount.reloadSerum3OpenOrders(client)
|
||||
// await readOnlyMangoAccount.reloadSerum3OpenOrders(client)
|
||||
set((state) => {
|
||||
state.mangoAccount.current = readOnlyMangoAccount
|
||||
state.mangoAccount.initialLoad = false
|
||||
})
|
||||
await actions.fetchOpenOrders()
|
||||
// await actions.fetchOpenOrders()
|
||||
} catch (error) {
|
||||
console.error('error', error)
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import useMangoGroup from 'hooks/useMangoGroup'
|
|||
import FormatNumericValue from './shared/FormatNumericValue'
|
||||
import { stakeAndCreate } from 'utils/transactions'
|
||||
import { MangoAccount } from '@blockworks-foundation/mango-v4'
|
||||
import { AnchorProvider } from '@project-serum/anchor'
|
||||
|
||||
const set = mangoStore.getState().set
|
||||
|
||||
|
@ -173,10 +174,15 @@ function DepositForm({ onSuccess, token: selectedToken }: DepositFormProps) {
|
|||
type: 'success',
|
||||
txid: tx,
|
||||
})
|
||||
|
||||
if (!mangoAccount) {
|
||||
await actions.fetchMangoAccounts(
|
||||
(client.program.provider as AnchorProvider).wallet.publicKey,
|
||||
)
|
||||
}
|
||||
await actions.reloadMangoAccount(slot)
|
||||
actions.fetchWalletTokens(publicKey)
|
||||
await actions.fetchWalletTokens(publicKey)
|
||||
setSubmitting(false)
|
||||
setInputAmount('')
|
||||
onSuccess()
|
||||
} catch (e) {
|
||||
console.error('Error depositing:', e)
|
||||
|
|
|
@ -617,8 +617,6 @@ const mangoStore = create<MangoStore>()(
|
|||
}
|
||||
} catch (e) {
|
||||
console.error('Error reloading mango acct', e)
|
||||
await actions.reloadMangoAccount()
|
||||
await sleep(100)
|
||||
} finally {
|
||||
set((state) => {
|
||||
state.mangoAccount.initialLoad = false
|
||||
|
@ -664,19 +662,18 @@ const mangoStore = create<MangoStore>()(
|
|||
console.error('Error parsing last account', e)
|
||||
}
|
||||
}
|
||||
console.log('newSelectedMangoAccount', newSelectedMangoAccount)
|
||||
|
||||
if (newSelectedMangoAccount) {
|
||||
await newSelectedMangoAccount.reloadSerum3OpenOrders(client)
|
||||
set((state) => {
|
||||
state.mangoAccount.current = newSelectedMangoAccount
|
||||
state.mangoAccount.initialLoad = false
|
||||
})
|
||||
actions.fetchOpenOrders()
|
||||
}
|
||||
// await newSelectedMangoAccount.reloadSerum3OpenOrders(client)
|
||||
set((state) => {
|
||||
state.mangoAccount.current = newSelectedMangoAccount
|
||||
state.mangoAccount.initialLoad = false
|
||||
})
|
||||
// actions.fetchOpenOrders()
|
||||
|
||||
await Promise.all(
|
||||
mangoAccounts.map((ma) => ma.reloadSerum3OpenOrders(client)),
|
||||
)
|
||||
// await Promise.all(
|
||||
// mangoAccounts.map((ma) => ma.reloadSerum3OpenOrders(client)),
|
||||
// )
|
||||
|
||||
set((state) => {
|
||||
state.mangoAccounts = mangoAccounts
|
||||
|
|
Loading…
Reference in New Issue