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 List from '@material-ui/core/List';
|
||||||
import ListItem from '@material-ui/core/ListItem';
|
import ListItem from '@material-ui/core/ListItem';
|
||||||
import ListItemText from '@material-ui/core/ListItemText';
|
import ListItemText from '@material-ui/core/ListItemText';
|
||||||
|
@ -57,16 +57,7 @@ const balanceFormat = new Intl.NumberFormat(undefined, {
|
||||||
useGrouping: true,
|
useGrouping: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function BalancesList() {
|
const serumMarkets = (() => {
|
||||||
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 m = {};
|
const m = {};
|
||||||
MARKETS.forEach((market) => {
|
MARKETS.forEach((market) => {
|
||||||
const coin = market.name.split('/')[0];
|
const coin = market.name.split('/')[0];
|
||||||
|
@ -85,9 +76,18 @@ export default function BalancesList() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return m;
|
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 (
|
return (
|
||||||
<Paper>
|
<Paper>
|
||||||
|
@ -127,11 +127,7 @@ export default function BalancesList() {
|
||||||
</AppBar>
|
</AppBar>
|
||||||
<List disablePadding>
|
<List disablePadding>
|
||||||
{publicKeys.map((publicKey) => (
|
{publicKeys.map((publicKey) => (
|
||||||
<BalanceListItem
|
<BalanceListItem key={publicKey.toBase58()} publicKey={publicKey} />
|
||||||
key={publicKey.toBase58()}
|
|
||||||
publicKey={publicKey}
|
|
||||||
serumMarkets={serumMarkets}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
{loaded ? null : <LoadingIndicator />}
|
{loaded ? null : <LoadingIndicator />}
|
||||||
</List>
|
</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 balanceInfo = useBalanceInfo(publicKey);
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const connection = useConnection();
|
const connection = useConnection();
|
||||||
|
@ -199,7 +195,7 @@ export function BalanceListItem({ publicKey, serumMarkets, expandable }) {
|
||||||
setPrice(null);
|
setPrice(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [serumMarkets, price, balanceInfo, connection]);
|
}, [price, balanceInfo, connection]);
|
||||||
|
|
||||||
expandable = expandable === undefined ? true : expandable;
|
expandable = expandable === undefined ? true : expandable;
|
||||||
|
|
||||||
|
@ -462,7 +458,6 @@ class PriceStore {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.cache[marketName] === undefined) {
|
if (this.cache[marketName] === undefined) {
|
||||||
this.cache[marketName] = null;
|
|
||||||
fetch(`https://serum-api.bonfida.com/orderbooks/${marketName}`).then(
|
fetch(`https://serum-api.bonfida.com/orderbooks/${marketName}`).then(
|
||||||
(resp) => {
|
(resp) => {
|
||||||
resp.json().then((resp) => {
|
resp.json().then((resp) => {
|
||||||
|
|
Loading…
Reference in New Issue