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

Fix broken token images #4169

Merged
merged 1 commit into from
Jan 13, 2017
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
14 changes: 9 additions & 5 deletions js/src/ui/Balance/balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ class Balance extends Component {
value = api.util.fromWei(balance.value).toFormat(3);
}

let imagesrc = token.image;
if (!imagesrc) {
imagesrc = images[token.address]
? `${api.dappsUrl}${images[token.address]}`
: unknownImage;
const imageurl = token.image || images[token.address];
let imagesrc = unknownImage;

if (imageurl) {
const host = /^(\/)?api/.test(imageurl)
? api.dappsUrl
: '';

imagesrc = `${host}${imageurl}`;
}

return (
Expand Down
8 changes: 6 additions & 2 deletions js/src/ui/Form/TypedInput/typedInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ export default class TypedInput extends Component {
const { isEth, value } = this.props;

if (typeof isEth === 'boolean' && value) {
const ethValue = isEth ? fromWei(value) : value;
// Remove formatting commas
const sanitizedValue = typeof value === 'string' ? value.replace(/,/g, '') : value;
const ethValue = isEth ? fromWei(sanitizedValue) : value;
this.setState({ isEth, ethValue });
}
}
Expand Down Expand Up @@ -393,7 +395,9 @@ export default class TypedInput extends Component {
return this.setState({ isEth: !isEth });
}

const value = isEth ? toWei(ethValue) : fromWei(ethValue);
// Remove formatting commas
const sanitizedValue = typeof ethValue === 'string' ? ethValue.replace(/,/g, '') : ethValue;
const value = isEth ? toWei(sanitizedValue) : fromWei(sanitizedValue);
this.setState({ isEth: !isEth, ethValue: value }, () => {
this.onEthValueChange(null, value);
});
Expand Down