From b1fb65b1ec9d6bcecdadb18f98629887819bf9f2 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 12 Feb 2018 19:01:29 -0800 Subject: [PATCH] renamed existing request --- react/components/AssetDisplay/index.js | 4 +- react/components/AssetTitle/index.js | 4 +- react/components/ShowAssetLite/index.js | 4 +- .../containers/ChannelClaimsDisplay/index.js | 11 +++--- react/containers/ShowAsset/index.js | 39 +++++++++++-------- react/containers/ShowAsset/view.jsx | 12 +++--- react/containers/ShowChannel/index.js | 35 +++++++++-------- react/containers/ShowChannel/view.jsx | 12 +++--- 8 files changed, 64 insertions(+), 57 deletions(-) diff --git a/react/components/AssetDisplay/index.js b/react/components/AssetDisplay/index.js index 26eadbe2..54e55e71 100644 --- a/react/components/AssetDisplay/index.js +++ b/react/components/AssetDisplay/index.js @@ -8,8 +8,8 @@ const mapStateToProps = ({ show }) => { status: show.displayAsset.status, }; // select asset info - const existingRequest = show.assetRequests[show.request.id]; - const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`; + const previousRequest = show.assetRequests[show.request.id]; + const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`; const asset = show.assetList[assetKey]; if (asset) { props['asset'] = asset; diff --git a/react/components/AssetTitle/index.js b/react/components/AssetTitle/index.js index abec748a..f68dab60 100644 --- a/react/components/AssetTitle/index.js +++ b/react/components/AssetTitle/index.js @@ -4,8 +4,8 @@ import View from './view'; const mapStateToProps = ({ show }) => { let props = {}; // select title - const existingRequest = show.assetRequests[show.request.id]; - const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`; + const previousRequest = show.assetRequests[show.request.id]; + const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`; const asset = show.assetList[assetKey]; if (asset) { props['title'] = asset.claimData.title; diff --git a/react/components/ShowAssetLite/index.js b/react/components/ShowAssetLite/index.js index 61f50437..8ab7fb18 100644 --- a/react/components/ShowAssetLite/index.js +++ b/react/components/ShowAssetLite/index.js @@ -4,8 +4,8 @@ import View from './view'; const mapStateToProps = ({ show }) => { let props = {}; // select name and claim id - const existingRequest = show.assetRequests[show.request.id]; - const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`; + const previousRequest = show.assetRequests[show.request.id]; + const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`; const asset = show.assetList[assetKey]; if (asset) { props['name'] = asset.name; diff --git a/react/containers/ChannelClaimsDisplay/index.js b/react/containers/ChannelClaimsDisplay/index.js index 4c9bd356..80c075dc 100644 --- a/react/containers/ChannelClaimsDisplay/index.js +++ b/react/containers/ChannelClaimsDisplay/index.js @@ -3,17 +3,16 @@ import { updateChannelClaimsAsync } from 'actions/show'; import View from './view'; const mapStateToProps = ({ show }) => { - let props = {}; // select channel key const request = show.channelRequests[show.request.id]; const channelKey = `c#${request.name}#${request.longId}`; - props['channelKey'] = channelKey; // select channel claims - const channel = show.channelList[channelKey]; - if (channel) { - props['channel'] = channel; + const channel = show.channelList[channelKey] || null; + // return props + return { + channelKey, + channel, }; - return props; }; const mapDispatchToProps = dispatch => { diff --git a/react/containers/ShowAsset/index.js b/react/containers/ShowAsset/index.js index 79cca1a2..8eb76e9d 100644 --- a/react/containers/ShowAsset/index.js +++ b/react/containers/ShowAsset/index.js @@ -3,25 +3,30 @@ import View from './view'; import { newAssetRequest, showNewAsset } from 'actions/show'; const mapStateToProps = ({ show }) => { - let props = {}; - props['requestType'] = show.request.type; - props['requestId'] = show.request.id; - props['requestName'] = show.request.data.name; - props['requestModifier'] = show.request.data.modifier; - props['requestExtension'] = show.request.data.extension; + // select request info + const requestType = show.request.type; + const requestId = show.request.id; + const requestName = show.request.data.name; + const requestModifier = show.request.data.modifier; + const requestExtension = show.request.data.extension; // select request - const existingRequest = show.assetRequests[show.request.id]; - if (existingRequest) { - props['existingRequest'] = existingRequest; - // select asset info - const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`; // note: just store this in the request - const asset = show.assetList[assetKey]; - if (asset) { - console.log('existing asset found', asset); - props['asset'] = asset; - }; + const previousRequest = show.assetRequests[show.request.id] || null; + // select asset infogit + let asset; + if (previousRequest) { + const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`; // note: just store this in the request + asset = show.assetList[assetKey] || null; + }; + // return props + return { + requestType, + requestId, + requestName, + requestModifier, + requestExtension, + previousRequest, + asset, }; - return props; }; const mapDispatchToProps = dispatch => { diff --git a/react/containers/ShowAsset/view.jsx b/react/containers/ShowAsset/view.jsx index 87f75a91..6cf7cfb9 100644 --- a/react/containers/ShowAsset/view.jsx +++ b/react/containers/ShowAsset/view.jsx @@ -11,23 +11,23 @@ function requestIsAnAssetRequest ({ requestType }) { class ShowAsset extends React.Component { componentDidMount () { - const { asset, existingRequest, requestId, requestName, requestModifier } = this.props; - if (!existingRequest) { // case: the asset request does not exist + const { asset, previousRequest, requestId, requestName, requestModifier } = this.props; + if (!previousRequest) { // case: the asset request does not exist return this.props.onNewRequest(requestId, requestName, requestModifier); }; if (!asset) { // case: the asset request does not exist - const { name, claimId } = existingRequest; + const { name, claimId } = previousRequest; return this.props.onShowNewAsset(name, claimId); }; } componentWillReceiveProps (nextProps) { if (requestIsAnAssetRequest(nextProps)) { - const { asset, existingRequest, requestId, requestName, requestModifier } = nextProps; - if (!existingRequest) { + const { asset, previousRequest, requestId, requestName, requestModifier } = nextProps; + if (!previousRequest) { return this.props.onNewRequest(requestId, requestName, requestModifier); }; if (!asset) { - const { name, claimId } = existingRequest; + const { name, claimId } = previousRequest; return this.props.onShowNewAsset(name, claimId); }; } diff --git a/react/containers/ShowChannel/index.js b/react/containers/ShowChannel/index.js index 7ddfef82..ace8f8fb 100644 --- a/react/containers/ShowChannel/index.js +++ b/react/containers/ShowChannel/index.js @@ -4,24 +4,27 @@ import { newChannelRequest, showNewChannel } from 'actions/show'; import View from './view'; const mapStateToProps = ({ show }) => { - let props = {}; - props['requestId'] = show.request.id; - props['requestType'] = show.request.type; - props['requestChannelName'] = show.request.data.name; - props['requestChannelId'] = show.request.data.id; + // select request info + const requestId = show.request.id; + const requestType = show.request.type; + const requestChannelName = show.request.data.name; + const requestChannelId = show.request.data.id; // select request - const existingRequest = show.channelRequests[show.request.id]; - if (existingRequest) { - props['existingRequest'] = existingRequest; - console.log('existing channel request found', existingRequest); - // select channel info - const channelKey = `c#${existingRequest.name}#${existingRequest.longId}`; - const channel = show.channelList[channelKey]; - if (channel) { - props['channel'] = channel; - }; + const previousRequest = show.channelRequests[show.request.id] || null; + // select channel info + let channel; + if (previousRequest) { + const channelKey = `c#${previousRequest.name}#${previousRequest.longId}`; + channel = show.channelList[channelKey] || null; } - return props; + return { + requestId, + requestType, + requestChannelName, + requestChannelId, + previousRequest, + channel, + }; }; const mapDispatchToProps = dispatch => { diff --git a/react/containers/ShowChannel/view.jsx b/react/containers/ShowChannel/view.jsx index 497faab5..fee7afab 100644 --- a/react/containers/ShowChannel/view.jsx +++ b/react/containers/ShowChannel/view.jsx @@ -11,23 +11,23 @@ function requestIsAChannelRequest ({ requestType }) { class ShowChannel extends React.Component { componentDidMount () { - const { existingRequest, channel, requestId, requestChannelName, requestChannelId } = this.props; - if (!existingRequest) { + const { previousRequest, channel, requestId, requestChannelName, requestChannelId } = this.props; + if (!previousRequest) { return this.props.onNewChannelRequest(requestId, requestChannelName, requestChannelId); } if (!channel) { - const { name, shortId, longId } = existingRequest; + const { name, shortId, longId } = previousRequest; return this.props.onShowNewChannel(name, shortId, longId); } } componentWillReceiveProps (nextProps) { if (requestIsAChannelRequest(nextProps)) { - const { existingRequest, channel, requestId, requestChannelName, requestChannelId } = nextProps; - if (!existingRequest) { + const { previousRequest, channel, requestId, requestChannelName, requestChannelId } = nextProps; + if (!previousRequest) { return this.props.onNewChannelRequest(requestId, requestChannelName, requestChannelId); } if (!channel) { - const { name, shortId, longId } = existingRequest; + const { name, shortId, longId } = previousRequest; return this.props.onShowNewChannel(name, shortId, longId); } }