Merge pull request #144 from 6ea86b96/bug/cost-info-lookup

Lookup cost info on file page if it hasn't already been looked up
This commit is contained in:
Jeremy Kauffman 2017-05-26 14:19:16 -04:00 committed by GitHub
commit dff389d8cf
2 changed files with 12 additions and 1 deletions

View file

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

View file

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