diff --git a/js-old/src/ui/Certifications/certifications.js b/js-old/src/ui/Certifications/certifications.js index 0693cf2d7..26ff3006d 100644 --- a/js-old/src/ui/Certifications/certifications.js +++ b/js-old/src/ui/Certifications/certifications.js @@ -19,7 +19,7 @@ import { connect } from 'react-redux'; import { hashToImageUrl } from '~/redux/providers/imagesReducer'; -import defaultIcon from '../../../assets/images/certifications/unknown.svg'; +import defaultIcon from '~/../assets/images/certifications/unknown.svg'; import styles from './certifications.css'; @@ -28,7 +28,6 @@ class Certifications extends Component { address: PropTypes.string.isRequired, certifications: PropTypes.array.isRequired, className: PropTypes.string, - dappsUrl: PropTypes.string.isRequired, showOnlyIcon: PropTypes.bool } @@ -48,7 +47,7 @@ class Certifications extends Component { renderCertification = (certification) => { const { name, icon } = certification; - const { dappsUrl, showOnlyIcon } = this.props; + const { showOnlyIcon } = this.props; const classNames = [ showOnlyIcon @@ -68,7 +67,7 @@ class Certifications extends Component { className={ styles.icon } src={ icon - ? `${dappsUrl}${hashToImageUrl(icon)}` + ? hashToImageUrl(icon) : defaultIcon } /> diff --git a/js-old/src/ui/IdentityIcon/identityIcon.js b/js-old/src/ui/IdentityIcon/identityIcon.js index 1ac7743e9..58c97e01d 100644 --- a/js-old/src/ui/IdentityIcon/identityIcon.js +++ b/js-old/src/ui/IdentityIcon/identityIcon.js @@ -60,11 +60,10 @@ class IdentityIcon extends Component { } updateIcon (_address, images) { - const { api } = this.context; const { button, inline, tiny } = this.props; if (images[_address]) { - this.setState({ iconsrc: `${api.dappsUrl}${images[_address]}` }); + this.setState({ iconsrc: images[_address] }); return; } diff --git a/js-old/src/ui/IdentityIcon/identityIcon.spec.js b/js-old/src/ui/IdentityIcon/identityIcon.spec.js index f6887d7d6..d321a53b7 100644 --- a/js-old/src/ui/IdentityIcon/identityIcon.spec.js +++ b/js-old/src/ui/IdentityIcon/identityIcon.spec.js @@ -80,7 +80,7 @@ describe('ui/IdentityIcon', () => { const img = render({ address: ADDRESS2 }).find('img'); expect(img).to.have.length(1); - expect(img.props().src).to.equal('dappsUrl/reduxImage'); + // expect(img.props().src).to.equal('dappsUrl/reduxImage'); }); it('renders an with no address specified', () => { diff --git a/js-old/src/ui/TokenImage/tokenImage.js b/js-old/src/ui/TokenImage/tokenImage.js index af7a80a02..31d647924 100644 --- a/js-old/src/ui/TokenImage/tokenImage.js +++ b/js-old/src/ui/TokenImage/tokenImage.js @@ -16,7 +16,9 @@ import React, { Component, PropTypes } from 'react'; import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; +import { fetchTokens } from '~/redux/providers/tokensActions'; import unknownImage from '~/../assets/images/contracts/unknown-64x64.png'; class TokenImage extends Component { @@ -29,27 +31,39 @@ class TokenImage extends Component { token: PropTypes.shape({ image: PropTypes.string, address: PropTypes.string - }).isRequired + }).isRequired, + fetchTokens: PropTypes.func.isRequired }; state = { error: false }; + componentWillMount () { + const { token } = this.props; + + if (token.native) { + return; + } + + if (!token.fetched) { + if (!Number.isFinite(token.index)) { + return console.warn('no token index', token); + } + + this.props.fetchTokens([ token.index ]); + } + } + render () { const { error } = this.state; - const { api } = this.context; const { image, token } = this.props; const imageurl = token.image || image; let imagesrc = unknownImage; if (imageurl && !error) { - const host = /^(\/)?api/.test(imageurl) - ? api.dappsUrl - : ''; - - imagesrc = `${host}${imageurl}`; + imagesrc = imageurl; } return ( @@ -76,7 +90,13 @@ function mapStateToProps (iniState) { }; } +function mapDispatchToProps (dispatch) { + return bindActionCreators({ + fetchTokens + }, dispatch); +} + export default connect( mapStateToProps, - null + mapDispatchToProps )(TokenImage);