Refresh cached tokens based on registry info & random balances (#6818) (#6824)

* Refresh cached tokens based on registry info & random balances

* Don't display errored token images
This commit is contained in:
Jaco Greeff
2017-10-19 17:49:25 +02:00
committed by Arkadiy Paronyan
parent 9882902f31
commit 284fc65c70
3 changed files with 33 additions and 16 deletions

View File

@@ -32,14 +32,19 @@ class TokenImage extends Component {
}).isRequired
};
state = {
error: false
};
render () {
const { error } = this.state;
const { api } = this.context;
const { image, token } = this.props;
const imageurl = token.image || image;
let imagesrc = unknownImage;
if (imageurl) {
if (imageurl && !error) {
const host = /^(\/)?api/.test(imageurl)
? api.dappsUrl
: '';
@@ -49,11 +54,16 @@ class TokenImage extends Component {
return (
<img
src={ imagesrc }
alt={ token.name }
onError={ this.handleError }
src={ imagesrc }
/>
);
}
handleError = () => {
this.setState({ error: true });
};
}
function mapStateToProps (iniState) {