keep the order of mango account list static
This commit is contained in:
parent
830e944884
commit
5e05e92101
|
@ -52,10 +52,11 @@ const MangoAccountsListModal = ({
|
|||
if (!group) return mangoAccounts
|
||||
|
||||
return [...mangoAccounts].sort((a, b) => {
|
||||
if (b.publicKey.toString() === mangoAccount?.publicKey.toString())
|
||||
return 1
|
||||
if (a.publicKey.toString() === mangoAccount?.publicKey.toString())
|
||||
return -1
|
||||
// keeps the current selected mango account at the top of the list
|
||||
// if (b.publicKey.toString() === mangoAccount?.publicKey.toString())
|
||||
// return 1
|
||||
// if (a.publicKey.toString() === mangoAccount?.publicKey.toString())
|
||||
// return -1
|
||||
return b.getEquity(group).toNumber() - a.getEquity(group).toNumber()
|
||||
})
|
||||
}, [group, mangoAccounts])
|
||||
|
|
|
@ -660,6 +660,12 @@ const mangoStore = create<MangoStore>()(
|
|||
const { value: reloadedMangoAccount, slot } =
|
||||
await mangoAccount.reloadWithSlot(client)
|
||||
if (slot > lastSlot) {
|
||||
const ma = get().mangoAccounts.find((ma) =>
|
||||
ma.publicKey.equals(reloadedMangoAccount.publicKey)
|
||||
)
|
||||
if (ma) {
|
||||
Object.assign(ma, reloadedMangoAccount)
|
||||
}
|
||||
set((state) => {
|
||||
state.mangoAccount.current = reloadedMangoAccount
|
||||
state.mangoAccount.lastSlot = slot
|
||||
|
|
Loading…
Reference in New Issue