diff --git a/react/components/ShowAssetLite/index.js b/react/components/ShowAssetLite/index.js
index b47c7407..899555e6 100644
--- a/react/components/ShowAssetLite/index.js
+++ b/react/components/ShowAssetLite/index.js
@@ -3,8 +3,7 @@ import View from './view';
const mapStateToProps = ({ show }) => {
return {
- name : show.showAsset.claimData.name,
- claimId: show.showAsset.claimData.claimId,
+ asset: show.assetList[show.showAsset.id],
};
};
diff --git a/react/components/ShowAssetLite/view.jsx b/react/components/ShowAssetLite/view.jsx
index 74dc1beb..d9892d90 100644
--- a/react/components/ShowAssetLite/view.jsx
+++ b/react/components/ShowAssetLite/view.jsx
@@ -4,7 +4,7 @@ import AssetDisplay from 'components/AssetDisplay';
class ShowLite extends React.Component {
render () {
- const { name, claimId } = this.props;
+ const { asset: { name, claimId } } = this.props;
return (
{ (name && claimId) &&
diff --git a/react/constants/show_action_types.js b/react/constants/show_action_types.js
index d4d262f8..26302b22 100644
--- a/react/constants/show_action_types.js
+++ b/react/constants/show_action_types.js
@@ -11,7 +11,7 @@ export const SHOW_ASSET_NEW = 'SHOW_ASSET_NEW';
export const SHOW_ASSET_UPDATE = 'SHOW_ASSET_UPDATE';
export const SHOW_ASSET_CLEAR = 'SHOW_ASSET_CLEAR';
-export const ASSET_LIST_ADD = `ASSET_LIST_ADD`;
+export const ASSET_LIST_UPSERT = `ASSET_LIST_UPSERT`;
// channel request actions
export const CHANNEL_REQUEST_NEW = 'CHANNEL_REQUEST_NEW';
diff --git a/react/containers/ShowAsset/index.js b/react/containers/ShowAsset/index.js
index 6f5ce1b6..e375e2ab 100644
--- a/react/containers/ShowAsset/index.js
+++ b/react/containers/ShowAsset/index.js
@@ -13,25 +13,25 @@ const mapStateToProps = ({ show }) => {
assetList : show.assetList,
// show asset
error : show.showAsset.error,
- name : show.showAsset.name,
- claimData : show.showAsset.claimData,
+ id : show.showAsset.id,
};
};
const mapDispatchToProps = dispatch => {
return {
- // new
+ // request
onNewRequest: (id, name, modifier) => {
dispatch(newAssetRequest(id, name, modifier));
},
onRequestError: (error) => {
dispatch(updateRequestError(error, null, null));
},
+ // show asset
onShowNewAsset: (name, claimId) => {
dispatch(showNewAsset(name, claimId));
},
- onShowExistingAsset: (error, name, claimId, shortId, claimData) => {
- dispatch(updateShowAsset(error, name, claimId, shortId, claimData));
+ onShowExistingAsset: (assetId) => {
+ dispatch(updateShowAsset(null, assetId));
},
onLeaveShowAsset: () => {
dispatch(clearShowAsset()); // clear any errors
diff --git a/react/containers/ShowAsset/view.jsx b/react/containers/ShowAsset/view.jsx
index 123ed807..3e3de33d 100644
--- a/react/containers/ShowAsset/view.jsx
+++ b/react/containers/ShowAsset/view.jsx
@@ -52,7 +52,7 @@ class ShowAsset extends React.Component {
const assetId = `a#${name}#${claimId}`;
const existingAssetRecord = assetList[assetId];
if (existingAssetRecord) { // case: the asset data already exists
- this.showExistingAsset(existingAssetRecord);
+ this.showExistingAsset(assetId);
} else { // case: the asset data does not exist yet
this.showNewAsset(name, claimId);
}
@@ -60,21 +60,20 @@ class ShowAsset extends React.Component {
showNewAsset (name, claimId) {
this.props.onShowNewAsset(name, claimId);
}
- showExistingAsset (existingAssetRecord) {
- let { error, name, claimId, shortId, claimData } = existingAssetRecord;
- this.props.onShowExistingAsset(error, name, claimId, shortId, claimData);
+ showExistingAsset (assetId) {
+ this.props.onShowExistingAsset(assetId);
}
componentWillUnmount () {
this.props.onLeaveShowAsset();
}
render () {
- const { error, name, requestExtension } = this.props;
+ const { error, id, requestExtension } = this.props;
if (error) {
return (
);
}
- if (name) { // direct requests are passing because name is present so it just goes
+ if (id) { // direct requests are passing because name is present so it just goes
if (requestExtension) {
return (
diff --git a/react/reducers/show.js b/react/reducers/show.js
index 5e1a7ac4..3a78bc2f 100644
--- a/react/reducers/show.js
+++ b/react/reducers/show.js
@@ -24,11 +24,8 @@ const initialState = {
},
},
showAsset: {
- error : null,
- name : null,
- claimId : null,
- shortId : null,
- claimData: null,
+ error: null,
+ id : null,
},
displayAsset: {
error : null,
@@ -93,25 +90,19 @@ export default function (state = initialState, action) {
case actions.SHOW_ASSET_UPDATE:
return Object.assign({}, state, {
showAsset: Object.assign({}, state.showAsset, {
- error : action.data.error,
- name : action.data.name,
- claimId : action.data.claimId,
- shortId : action.data.shortId,
- claimData: action.data.claimData,
+ error: action.data.error,
+ id : action.data.id,
}),
});
case actions.SHOW_ASSET_CLEAR:
return Object.assign({}, state, {
showAsset: Object.assign({}, state.showAsset, {
- error : null,
- name : null,
- claimId : null,
- shortId : null,
- claimData: null,
+ error: null,
+ id : null,
}),
});
// add asset to asset list
- case actions.ASSET_LIST_ADD:
+ case actions.ASSET_LIST_UPSERT:
return Object.assign({}, state, {
assetList: Object.assign({}, state.assetList, {
[action.data.id]: {
diff --git a/react/sagas/show_asset.js b/react/sagas/show_asset.js
index 61761c89..1b99e5b6 100644
--- a/react/sagas/show_asset.js
+++ b/react/sagas/show_asset.js
@@ -1,6 +1,6 @@
import { call, put, takeLatest } from 'redux-saga/effects';
import * as actions from 'constants/show_action_types';
-import { updateShowAsset, addAssetToAssetList } from 'actions/show';
+import { updateShowAsset, upsertAssetToAssetList } from 'actions/show';
import { getShortId, getClaimData } from 'api/assetApi';
function* getAssetDataAndShowAsset (action) {
@@ -10,10 +10,10 @@ function* getAssetDataAndShowAsset (action) {
try {
({success, message, data: shortId} = yield call(getShortId, name, claimId));
} catch (error) {
- return yield put(updateShowAsset(error.message, name, claimId));
+ return yield put(updateShowAsset(error.message, null));
}
if (!success) {
- return yield put(updateShowAsset(message, name, claimId));
+ return yield put(updateShowAsset(message, null));
}
// if no error, get claim data
success = null;
@@ -21,13 +21,13 @@ function* getAssetDataAndShowAsset (action) {
try {
({success, message, data: claimData} = yield call(getClaimData, name, claimId));
} catch (error) {
- return yield put(updateShowAsset(error.message, name, claimId));
+ return yield put(updateShowAsset(error.message, null));
}
if (!success) {
- return yield put(updateShowAsset(message, name, claimId));
+ return yield put(updateShowAsset(message, null));
}
- yield put(updateShowAsset(null, name, claimId, shortId, claimData));
- yield put(addAssetToAssetList(id, null, name, claimId, shortId, claimData));
+ yield put(updateShowAsset(null, id));
+ yield put(upsertAssetToAssetList(id, null, name, claimId, shortId, claimData));
}
export function* watchShowNewAsset () {