Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Be lenient around invalid owners map #3764

Merged
merged 2 commits into from
Dec 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions js/src/views/Accounts/Summary/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

import BigNumber from 'bignumber.js';
import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import { isEqual } from 'lodash';
Expand Down Expand Up @@ -113,15 +114,16 @@ export default class Summary extends Component {

renderOwners () {
const { owners } = this.props;
const ownersValid = (owners || []).filter((owner) => owner.address && new BigNumber(owner.address).gt(0));

if (!owners || owners.length === 0) {
if (!ownersValid || ownersValid.length === 0) {
return null;
}

return (
<div className={ styles.owners }>
{
owners.map((owner) => (
ownersValid.map((owner) => (
<div key={ owner.address }>
<div
data-tip
Expand Down
18 changes: 11 additions & 7 deletions js/src/views/Accounts/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,17 @@ function mapStateToProps (state) {

const walletsOwners = Object
.keys(walletsInfo)
.map((wallet) => ({
owners: walletsInfo[wallet].owners.map((owner) => ({
address: owner,
name: accountsInfo[owner] && accountsInfo[owner].name || owner
})),
address: wallet
}))
.map((wallet) => {
const owners = walletsInfo[wallet].owners || [];

return {
owners: owners.map((owner) => ({
address: owner,
name: accountsInfo[owner] && accountsInfo[owner].name || owner
})),
address: wallet
};
})
.reduce((walletsOwners, wallet) => {
walletsOwners[wallet.address] = wallet.owners;
return walletsOwners;
Expand Down