Skip to content

Commit

Permalink
♻️ change address fieldName of currentPeer mixed up with account addr…
Browse files Browse the repository at this point in the history
…ess state
  • Loading branch information
faival committed Jul 12, 2018
1 parent 8cfc124 commit 7efa829
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/components/savedAccounts/accountCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const AccountCard = ({
null)}
{(account.network !== networks.mainnet.code ?
<strong className={styles.network}>
{account.address ? account.address : t(getNetwork(account.network).name)}
{account.peerAddress ? account.peerAddress : t(getNetwork(account.network).name)}
</strong> :
null)}
<div className={styles.cardIcon}>
Expand Down
5 changes: 3 additions & 2 deletions src/store/middlewares/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ const loginMiddleware = store => next => (action) => {
}
next(action);

const { passphrase, activePeer } = action.data;
const { passphrase, activePeer, options } = action.data;
const publicKey = passphrase ? extractPublicKey(passphrase) : action.data.publicKey;
const address = extractAddress(publicKey);
const accountBasics = {
passphrase,
publicKey,
address,
network: activePeer.currentNode,
network: options.code,
peerAddress: options.address,
};

store.dispatch(accountLoading());
Expand Down
4 changes: 2 additions & 2 deletions src/store/middlewares/savedAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const savedAccountsMiddleware = (store) => {
passphrase: action.data.passphrase,
network: {
...getNetwork(action.data.network),
address: action.data.address,
address: action.data.peerAddress,
},
}));
break;
Expand All @@ -103,7 +103,7 @@ const savedAccountsMiddleware = (store) => {
balance: action.data.balance,
publicKey: action.data.publicKey,
network: peers.options.code,
address: action.data.network,
peerAddress: action.data.peerAddress,
}));
break;
case actionTypes.accountRemoved:
Expand Down
28 changes: 14 additions & 14 deletions src/store/reducers/savedAccounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ const savedAccounts = (state = { accounts: [] }, action) => {
accounts,
lastActive: changedAccount,
};
// case actionTypes.passphraseUsed:
// indexOfAccount = getIndexOfSavedAccount(state.accounts, state.lastActive);
// accounts[indexOfAccount] = {
// ...accounts[indexOfAccount],
// passphrase: action.data,
// };
// return {
// accounts,
// lastActive: {
// ...state.lastActive,
// passphrase: action.data,
// },
// };
case actionTypes.passphraseUsed:
indexOfAccount = getIndexOfSavedAccount(state.accounts, state.lastActive);
accounts[indexOfAccount] = {
...accounts[indexOfAccount],
passphrase: action.data,
};
return {
accounts,
lastActive: {
...state.lastActive,
passphrase: action.data,
},
};
case actionTypes.accountSwitched:
return {
...state,
Expand All @@ -64,7 +64,7 @@ const savedAccounts = (state = { accounts: [] }, action) => {
...state,
accounts: state.accounts.map((account) => {
if (!action.data ||
(action.data.network.indexOf(account.address) > -1 &&
(action.data.peerAddress === account.peerAddress &&
action.data.passphrase === account.passphrase)) {
delete account.passphrase;
}
Expand Down

0 comments on commit 7efa829

Please sign in to comment.