Skip to content

Commit

Permalink
Merge pull request #651 from Psychedelic/fix/wallet-info-switch
Browse files Browse the repository at this point in the history
Fix/wallet info switch
  • Loading branch information
tomiir authored Oct 24, 2022
2 parents 47a40aa + 065bc0f commit a5dfcca
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 2 additions & 4 deletions source/components/Profile/components/AccountItem/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ const AccountItem = ({
classes.accountItemContainer,
isHidden && classes.hiddenAccount,
)}
onClick={(e) => handleChangeAccount(e, account.walletId)}
>
<div
onClick={(e) => handleChangeAccount(e, account.walletId)}
className={classes.leftContainer}
>
<div className={classes.leftContainer}>
<UserIcon
size="small"
icon={account?.icon ?? '👽'}
Expand Down
10 changes: 3 additions & 7 deletions source/views/Extension/Views/WalletDetails/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const WalletDetails = () => {
const [connectedWallets, setConnectedWallets] = useState([]);
const [tab, setTab] = useState(null);
const [app, setApp] = useState(null);
const [accountSwitchId, setAccountSwitchId] = useState(walletId);
const [accounts, setAccounts] = useState([]);
const [openEmojis, setOpenEmojis] = useState(false);
const [walletName, setWalletName] = useState(name);
Expand Down Expand Up @@ -218,9 +217,6 @@ const WalletDetails = () => {
const url = getTabURL(tabs?.[0]);
const ids = accounts.map((account) => account.walletId);
setTab(tabs?.[0]);
// Check if new wallet is connected to the current page
setAccountSwitchId(walletId);

if (!ids.length) {
executeAccountSwitch(walletId);
return;
Expand All @@ -246,12 +242,12 @@ const WalletDetails = () => {
};

const executeAccountSwitch = (wallet) => {
sendMessage({ type: HANDLER_TYPES.SET_CURRENT_PRINCIPAL, params: accountSwitchId },
sendMessage({ type: HANDLER_TYPES.SET_CURRENT_PRINCIPAL, params: wallet },
(state) => {
if (Object.values(state?.wallets).length) {
const newWallet = state.wallets[state.currentWalletId];
dispatch(setAccountInfo(newWallet));
dipatch(getContacts());
dispatch(getContacts());
dispatch(setICNSData(newWallet.icnsData));
dispatch(setAssetsLoading(true));
dispatch(setTransactions([]));
Expand All @@ -275,7 +271,7 @@ const WalletDetails = () => {
useEffect(() => {
sendMessage({ type: HANDLER_TYPES.GET_STATE, params: {} }, (state) => {
if (Object.keys(state?.wallets)?.length) {
setAccounts(state.wallets);
setAccounts(Object.values(state.wallets));
}
});
}, []);
Expand Down

0 comments on commit a5dfcca

Please sign in to comment.