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
|
if (!group) return mangoAccounts
|
||||||
|
|
||||||
return [...mangoAccounts].sort((a, b) => {
|
return [...mangoAccounts].sort((a, b) => {
|
||||||
if (b.publicKey.toString() === mangoAccount?.publicKey.toString())
|
// keeps the current selected mango account at the top of the list
|
||||||
return 1
|
// if (b.publicKey.toString() === mangoAccount?.publicKey.toString())
|
||||||
if (a.publicKey.toString() === mangoAccount?.publicKey.toString())
|
// return 1
|
||||||
return -1
|
// if (a.publicKey.toString() === mangoAccount?.publicKey.toString())
|
||||||
|
// return -1
|
||||||
return b.getEquity(group).toNumber() - a.getEquity(group).toNumber()
|
return b.getEquity(group).toNumber() - a.getEquity(group).toNumber()
|
||||||
})
|
})
|
||||||
}, [group, mangoAccounts])
|
}, [group, mangoAccounts])
|
||||||
|
|
|
@ -660,6 +660,12 @@ const mangoStore = create<MangoStore>()(
|
||||||
const { value: reloadedMangoAccount, slot } =
|
const { value: reloadedMangoAccount, slot } =
|
||||||
await mangoAccount.reloadWithSlot(client)
|
await mangoAccount.reloadWithSlot(client)
|
||||||
if (slot > lastSlot) {
|
if (slot > lastSlot) {
|
||||||
|
const ma = get().mangoAccounts.find((ma) =>
|
||||||
|
ma.publicKey.equals(reloadedMangoAccount.publicKey)
|
||||||
|
)
|
||||||
|
if (ma) {
|
||||||
|
Object.assign(ma, reloadedMangoAccount)
|
||||||
|
}
|
||||||
set((state) => {
|
set((state) => {
|
||||||
state.mangoAccount.current = reloadedMangoAccount
|
state.mangoAccount.current = reloadedMangoAccount
|
||||||
state.mangoAccount.lastSlot = slot
|
state.mangoAccount.lastSlot = slot
|
||||||
|
|
Loading…
Reference in New Issue