fix for updating after cancel order

This commit is contained in:
Tyler Shipe 2021-04-15 18:45:26 -04:00
parent ecf81a41b8
commit 8d0019de47
3 changed files with 8 additions and 7 deletions

View File

@ -13,6 +13,7 @@ const OpenOrdersTable = () => {
const openOrders = useOpenOrders()
const [cancelId, setCancelId] = useState(null)
const { connection, programId } = useConnection()
const actions = useMangoStore((s) => s.actions)
const handleCancelOrder = async (order) => {
const wallet = useMangoStore.getState().wallet.current
@ -32,10 +33,7 @@ const OpenOrdersTable = () => {
order.market,
order
)
notify({
message: 'Order cancelled',
type: 'success',
})
actions.fetchMarginAccounts()
} catch (e) {
notify({
message: 'Error cancelling order',

View File

@ -62,7 +62,7 @@ export const useTradeHistory = () => {
if (marginAccount) {
actions.fetchTradeHistory()
}
}, 12000)
}, 60000)
const allTrades = []
if (eventQueueFills && eventQueueFills.length > 0) {

View File

@ -221,6 +221,7 @@ const useMangoStore = create<MangoStore>((set, get) => ({
const cluster = get().connection.cluster
const mangoClient = get().mangoClient
const programId = IDS[cluster].mango_program_id
const actions = get().actions
const set = get().set
if (!wallet?.publicKey || !wallet.publicKey) return
@ -238,6 +239,7 @@ const useMangoStore = create<MangoStore>((set, get) => ({
state.marginAccounts = marginAccounts
state.selectedMarginAccount.current = marginAccounts[0]
})
actions.fetchTradeHistory(marginAccounts[0])
}
})
.catch((err) => {
@ -276,8 +278,9 @@ const useMangoStore = create<MangoStore>((set, get) => ({
console.error('Could not get mango group: ', err)
})
},
async fetchTradeHistory() {
const selectedMarginAccount = get().selectedMarginAccount.current
async fetchTradeHistory(marginAccount = null) {
const selectedMarginAccount =
marginAccount || get().selectedMarginAccount.current
const set = get().set
if (!selectedMarginAccount) return