Add account with name

This commit is contained in:
Philippe Maes 2020-11-05 11:46:49 +01:00
parent ff94acd098
commit df5fc15d57
2 changed files with 7 additions and 3 deletions

View File

@ -140,6 +140,10 @@ function WalletSelector() {
<AddAccountDialog
open={addAccountOpen}
onClose={() => setAddAccountOpen(false)}
onAdd={(name) => {
setWalletIndex(accounts.length, name);
setAddAccountOpen(false);
}}
/>
<Hidden xsDown>
<Button

View File

@ -246,8 +246,9 @@ export function useBalanceInfo(publicKey) {
export function useWalletSelector() {
const { walletIndex, setWalletIndex, seed } = useContext(WalletContext);
const [walletCount, setWalletCount] = useLocalStorageState('walletCount', 1);
function selectWallet(walletIndex) {
function selectWallet(walletIndex, name) {
if (walletIndex >= walletCount) {
name && localStorage.setItem(`name${walletIndex}`, name);
setWalletCount(walletIndex + 1);
}
setWalletIndex(walletIndex);
@ -260,8 +261,7 @@ export function useWalletSelector() {
return [...Array(walletCount).keys()].map((walletIndex) => {
let address = Wallet.getAccountFromSeed(seedBuffer, walletIndex)
.publicKey;
let nameKey = `${address}Name`;
let name = localStorage.getItem(nameKey);
let name = localStorage.getItem(`name${walletIndex}`);
return { index: walletIndex, address, name };
});
}, [seed, walletCount]);