Fix account restoration view
This commit is contained in:
parent
1fa5f2ce96
commit
ff3d98b5c3
|
@ -1,4 +1,4 @@
|
|||
import React, { useState, useMemo, useEffect } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
|
@ -57,16 +57,7 @@ const balanceFormat = new Intl.NumberFormat(undefined, {
|
|||
useGrouping: true,
|
||||
});
|
||||
|
||||
export default function BalancesList() {
|
||||
const wallet = useWallet();
|
||||
const [publicKeys, loaded] = useWalletPublicKeys();
|
||||
const [showAddTokenDialog, setShowAddTokenDialog] = useState(false);
|
||||
const [showEditAccountNameDialog, setShowEditAccountNameDialog] = useState(
|
||||
false,
|
||||
);
|
||||
const { accounts, setAccountName } = useWalletSelector();
|
||||
const selectedAccount = accounts.find((a) => a.isSelected);
|
||||
const serumMarkets = useMemo(() => {
|
||||
const serumMarkets = (() => {
|
||||
const m = {};
|
||||
MARKETS.forEach((market) => {
|
||||
const coin = market.name.split('/')[0];
|
||||
|
@ -85,9 +76,18 @@ export default function BalancesList() {
|
|||
};
|
||||
}
|
||||
});
|
||||
|
||||
return m;
|
||||
}, []);
|
||||
})();
|
||||
|
||||
export default function BalancesList() {
|
||||
const wallet = useWallet();
|
||||
const [publicKeys, loaded] = useWalletPublicKeys();
|
||||
const [showAddTokenDialog, setShowAddTokenDialog] = useState(false);
|
||||
const [showEditAccountNameDialog, setShowEditAccountNameDialog] = useState(
|
||||
false,
|
||||
);
|
||||
const { accounts, setAccountName } = useWalletSelector();
|
||||
const selectedAccount = accounts.find((a) => a.isSelected);
|
||||
|
||||
return (
|
||||
<Paper>
|
||||
|
@ -127,11 +127,7 @@ export default function BalancesList() {
|
|||
</AppBar>
|
||||
<List disablePadding>
|
||||
{publicKeys.map((publicKey) => (
|
||||
<BalanceListItem
|
||||
key={publicKey.toBase58()}
|
||||
publicKey={publicKey}
|
||||
serumMarkets={serumMarkets}
|
||||
/>
|
||||
<BalanceListItem key={publicKey.toBase58()} publicKey={publicKey} />
|
||||
))}
|
||||
{loaded ? null : <LoadingIndicator />}
|
||||
</List>
|
||||
|
@ -170,7 +166,7 @@ const useStyles = makeStyles((theme) => ({
|
|||
},
|
||||
}));
|
||||
|
||||
export function BalanceListItem({ publicKey, serumMarkets, expandable }) {
|
||||
export function BalanceListItem({ publicKey, expandable }) {
|
||||
const balanceInfo = useBalanceInfo(publicKey);
|
||||
const classes = useStyles();
|
||||
const connection = useConnection();
|
||||
|
@ -199,7 +195,7 @@ export function BalanceListItem({ publicKey, serumMarkets, expandable }) {
|
|||
setPrice(null);
|
||||
}
|
||||
}
|
||||
}, [serumMarkets, price, balanceInfo, connection]);
|
||||
}, [price, balanceInfo, connection]);
|
||||
|
||||
expandable = expandable === undefined ? true : expandable;
|
||||
|
||||
|
@ -462,7 +458,6 @@ class PriceStore {
|
|||
return;
|
||||
}
|
||||
if (this.cache[marketName] === undefined) {
|
||||
this.cache[marketName] = null;
|
||||
fetch(`https://serum-api.bonfida.com/orderbooks/${marketName}`).then(
|
||||
(resp) => {
|
||||
resp.json().then((resp) => {
|
||||
|
|
Loading…
Reference in New Issue