diff --git a/react/actions/show.js b/react/actions/show.js index 4012e50a..61d79c6e 100644 --- a/react/actions/show.js +++ b/react/actions/show.js @@ -35,8 +35,9 @@ export function updateChannelClaimsData (claims, currentPage, totalPages, totalC }; }; -export function updateClaimData (claimData) { +export function updateClaimData (data) { return { - type: actions.CHANNEL_DATA_UPDATE, + type: actions.CLAIM_DATA_UPDATE, + data, }; }; diff --git a/react/components/ShowAssetDetails/index.js b/react/components/ShowAssetDetails/index.js index 3d3fa589..f4adce0c 100644 --- a/react/components/ShowAssetDetails/index.js +++ b/react/components/ShowAssetDetails/index.js @@ -27,7 +27,7 @@ class ShowDetails extends React.Component { { + return { + request: { + modifier : show.request.claim.modifier, + claim : show.request.claim.name, + extension: show.request.claim.extension, + }, + claim: show.claim, + }; +}; + +const mapDispatchToProps = dispatch => { + return { + onClaimDataChange: (data) => { + dispatch(updateClaimData(data)); + }, + }; +}; + +export default connect(mapStateToProps, mapDispatchToProps)(View); diff --git a/react/components/ShowAsset/index.js b/react/containers/ShowAsset/view.jsx similarity index 71% rename from react/components/ShowAsset/index.js rename to react/containers/ShowAsset/view.jsx index 616ae44e..58c9a776 100644 --- a/react/components/ShowAsset/index.js +++ b/react/containers/ShowAsset/view.jsx @@ -1,14 +1,13 @@ import React from 'react'; -import ShowAssetLite from 'components/ShowAssetLite'; -import ShowAssetDetails from 'components/ShowAssetDetails'; +import ShowAssetLite from 'components/ShowAssetLite/index'; +import ShowAssetDetails from 'components/ShowAssetDetails/index'; import request from 'utils/request'; class ShowAsset extends React.Component { constructor (props) { super(props); this.state = { - claimData: null, - error : null, + error: null, }; this.getLongClaimId = this.getLongClaimId.bind(this); this.getClaimData = this.getClaimData.bind(this); @@ -16,18 +15,19 @@ class ShowAsset extends React.Component { componentDidMount () { console.log('ShowAsset did mount'); console.log('ShowAsset props', this.props); + const modifier = this.props.request.modifier; + const name = this.props.request.claim; + // create request params let body = {}; - if (this.props.identifier) { - if (this.props.identifier.isChannel) { - body['channelName'] = this.props.identifier.channelName; - body['channelClaimId'] = this.props.identifier.channelClaimId; + if (modifier) { + if (modifier.channel) { + body['channelName'] = modifier.channel.name; + body['channelClaimId'] = modifier.channel.id; } else { - body['claimId'] = this.props.identifier.claimId; + body['claimId'] = modifier.id; } } - if (this.props.claim) { - body['claimName'] = this.props.claim.claimName; - } + body['claimName'] = name; const params = { method : 'POST', headers: new Headers({ @@ -35,13 +35,14 @@ class ShowAsset extends React.Component { }), body: JSON.stringify(body), } + // make request const that = this; this.getLongClaimId(params) .then(claimLongId => { - return that.getClaimData(this.props.claim.claimName, claimLongId); + return that.getClaimData(name, claimLongId); }) .then(claimData => { - this.setState({ claimData }); + this.props.onClaimDataChange(claimData); }) .catch(error => { this.setState({error}); @@ -81,26 +82,21 @@ class ShowAsset extends React.Component { }); } render () { - if (this.props.isServeRequest) { + if (this.props.request.extension) { return ( ); } return ( ); } }; -// required props -// identifier -// claim -// isServeRequest - export default ShowAsset; diff --git a/react/containers/ShowPage/view.jsx b/react/containers/ShowPage/view.jsx index f8e331cb..d818d85a 100644 --- a/react/containers/ShowPage/view.jsx +++ b/react/containers/ShowPage/view.jsx @@ -1,6 +1,6 @@ import React from 'react'; import ErrorPage from 'components/ErrorPage'; -import ShowAsset from 'components/ShowAsset'; +import ShowAsset from 'containers/ShowAsset'; import ShowChannel from 'containers/ShowChannel'; import lbryUri from 'utils/lbryUri'; @@ -109,11 +109,7 @@ class ShowPage extends React.Component { ); } else if (this.props.request.claim) { return ( - + ); } } diff --git a/react/reducers/show.js b/react/reducers/show.js index 1a12e393..2c9beb9c 100644 --- a/react/reducers/show.js +++ b/react/reducers/show.js @@ -16,11 +16,7 @@ const initialState = { totalClaims: null, }, }, - claim: { - name: null, - id : null, - data: null, - }, + claim: null, }; /* @@ -64,7 +60,7 @@ export default function (state = initialState, action) { }); case actions.CLAIM_DATA_UPDATE: return Object.assign({}, state, { - displayClaim: action.claimData, + claim: action.data, }); default: return state;