restore last viewed acct functionality
This commit is contained in:
parent
96f9945746
commit
8d28ab1cb6
|
@ -82,6 +82,7 @@ export default function useLocalStorageState<T = any>(
|
|||
try {
|
||||
return JSON.parse(stringState)
|
||||
} catch (e) {
|
||||
console.log('Error parsing JSON from localStorage', e)
|
||||
return stringState
|
||||
}
|
||||
}
|
||||
|
|
|
@ -622,11 +622,15 @@ const mangoStore = create<MangoStore>()(
|
|||
if (!selectedMangoAccount || !selectedAccountIsNotInAccountsList) {
|
||||
const lastAccount = localStorage.getItem(LAST_ACCOUNT_KEY)
|
||||
newSelectedMangoAccount = mangoAccounts[0]
|
||||
|
||||
let lastViewedAccount
|
||||
if (typeof lastAccount === 'string') {
|
||||
const lastViewedAccount = mangoAccounts.find(
|
||||
(m) => m.publicKey.toString() === lastAccount
|
||||
)
|
||||
try {
|
||||
lastViewedAccount = mangoAccounts.find(
|
||||
(m) => m.publicKey.toString() === JSON.parse(lastAccount)
|
||||
)
|
||||
} catch (e) {
|
||||
console.error('Error parsing last account', e)
|
||||
}
|
||||
newSelectedMangoAccount = lastViewedAccount || mangoAccounts[0]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export const LAST_ACCOUNT_KEY = 'mangoAccount-0.2'
|
||||
export const LAST_ACCOUNT_KEY = 'mangoAccount-0.3'
|
||||
|
||||
export const CLIENT_TX_TIMEOUT = 90000
|
||||
|
||||
|
|
Loading…
Reference in New Issue