Lookup cost info on file page if it hasn't already been looked up

This commit is contained in:
6ea86b96 2017-05-26 22:17:01 +04:00
parent 3bb08fd987
commit 82bdf6324d
No known key found for this signature in database
GPG key ID: B282D183E4931E8F
2 changed files with 12 additions and 1 deletions

View file

@ -11,6 +11,9 @@ import {
import {
makeSelectFileInfoForUri,
} from 'selectors/file_info'
import {
doFetchCostInfoForUri,
} from 'actions/cost_info'
import {
makeSelectClaimForUri,
makeSelectContentTypeForUri,
@ -41,7 +44,8 @@ const makeSelect = () => {
const perform = (dispatch) => ({
navigate: (path, params) => dispatch(doNavigate(path, params)),
fetchFileInfo: (uri) => dispatch(doFetchFileInfo(uri))
fetchFileInfo: (uri) => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: (uri) => dispatch(doFetchCostInfoForUri(uri)),
})
export default connect(makeSelect, perform)(FilePage)

View file

@ -46,6 +46,7 @@ class FilePage extends React.Component{
componentDidMount() {
this.fetchFileInfo(this.props)
this.fetchCostInfo(this.props)
}
componentWillReceiveProps(nextProps) {
@ -58,6 +59,12 @@ class FilePage extends React.Component{
}
}
fetchCostInfo(props) {
if (props.costInfo === undefined) {
props.fetchCostInfo(props.uri)
}
}
render() {
const {
claim,