updated to store and recall asset claim info and requests
This commit is contained in:
parent
6c10eeef71
commit
489153fcde
10 changed files with 196 additions and 155 deletions
|
@ -64,23 +64,6 @@ export function updateChannelClaimsData (claims, currentPage, totalPages, totalC
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function updateShowAssetError (error) {
|
|
||||||
return {
|
|
||||||
type: actions.SHOW_ASSET_ERROR,
|
|
||||||
data: error,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function updateAssetClaimData (data, shortId) {
|
|
||||||
return {
|
|
||||||
type: actions.ASSET_CLAIM_DATA_UPDATE,
|
|
||||||
data: {
|
|
||||||
data,
|
|
||||||
shortId,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export function fileRequested (name, claimId) {
|
export function fileRequested (name, claimId) {
|
||||||
return {
|
return {
|
||||||
type: actions.FILE_REQUESTED,
|
type: actions.FILE_REQUESTED,
|
||||||
|
@ -105,7 +88,7 @@ export function updateDisplayAssetError (error) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// new
|
// new: request-related actions
|
||||||
|
|
||||||
export function newAssetRequest (id, name, modifier) {
|
export function newAssetRequest (id, name, modifier) {
|
||||||
return {
|
return {
|
||||||
|
@ -114,16 +97,32 @@ export function newAssetRequest (id, name, modifier) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function addAssetRequest (id, error, claimId) {
|
export function addAssetRequest (id, error, name, claimId) {
|
||||||
return {
|
return {
|
||||||
type: actions.ASSET_REQUEST_ADD,
|
type: actions.ASSET_REQUEST_ADD,
|
||||||
data: { id, error, claimId },
|
data: { id, error, name, claimId },
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// export function addAsset (error, name, claimId, claimData, shortId, display) {
|
// new: asset-realted actions
|
||||||
// return {
|
|
||||||
// type: actions.ASSET_ADD,
|
export function showNewAsset (id, name, claimId) {
|
||||||
// data: { error, name, claimId, claimData, shortId, display },
|
console.log('show new asset', id, name, claimId);
|
||||||
// };
|
return {
|
||||||
// };
|
type: actions.SHOW_NEW_ASSET,
|
||||||
|
data: { id, name, claimId },
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function updateShowAsset (id, error, name, claimId, shortId, claimData) {
|
||||||
|
return {
|
||||||
|
type: actions.SHOW_ASSET_UPDATE,
|
||||||
|
data: { id, error, name, claimId, shortId, claimData },
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export function clearShowAsset () {
|
||||||
|
return {
|
||||||
|
type: actions.SHOW_ASSET_CLEAR,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
|
@ -23,4 +23,14 @@ export function getLongClaimId (name, modifier) {
|
||||||
const url = `/api/claim/long-id`;
|
const url = `/api/claim/long-id`;
|
||||||
// return the request promise
|
// return the request promise
|
||||||
return Request(url, params);
|
return Request(url, params);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export function getShortId (name, claimId) {
|
||||||
|
const url = `/api/claim/short-id/${claimId}/${name}`;
|
||||||
|
return Request(url);
|
||||||
|
};
|
||||||
|
|
||||||
|
export function getClaimData (name, claimId) {
|
||||||
|
const url = `/api/claim/data/${name}/${claimId}`;
|
||||||
|
return Request(url);
|
||||||
|
};
|
||||||
|
|
|
@ -36,7 +36,7 @@ class AssetInfo extends React.Component {
|
||||||
<span className="text">Channel:</span>
|
<span className="text">Channel:</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="column column--8 column--med-10">
|
<div className="column column--8 column--med-10">
|
||||||
<span className="text"><a href={`/${channelName}:${certificateId}`}>{channelName}</a></span>
|
<span className="text"><Link to={`/${channelName}:${certificateId}`}>{channelName}</Link></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,15 @@ export const SHOW_CHANNEL_ERROR = 'SHOW_CHANNEL_ERROR';
|
||||||
export const CHANNEL_DATA_UPDATE = 'CHANNEL_DATA_UPDATE';
|
export const CHANNEL_DATA_UPDATE = 'CHANNEL_DATA_UPDATE';
|
||||||
export const CHANNEL_CLAIMS_DATA_UPDATE = 'CHANNEL_CLAIMS_DATA_UPDATE';
|
export const CHANNEL_CLAIMS_DATA_UPDATE = 'CHANNEL_CLAIMS_DATA_UPDATE';
|
||||||
|
|
||||||
export const SHOW_ASSET_ERROR = 'SHOW_ASSET_ERROR';
|
export const SHOW_ASSET_UPDATE = 'SHOW_ASSET_UPDATE';
|
||||||
export const ASSET_CLAIM_DATA_UPDATE = 'ASSET_CLAIM_DATA_UPDATE';
|
export const ASSET_CLAIM_DATA_UPDATE = 'ASSET_CLAIM_DATA_UPDATE';
|
||||||
|
|
||||||
export const FILE_REQUESTED = 'FILE_REQUESTED';
|
export const FILE_REQUESTED = 'FILE_REQUESTED';
|
||||||
export const FILE_AVAILABILITY_UPDATE = 'FILE_AVAILABILITY_UPDATE';
|
export const FILE_AVAILABILITY_UPDATE = 'FILE_AVAILABILITY_UPDATE';
|
||||||
export const DISPLAY_ASSET_ERROR = 'DISPLAY_ASSET_ERROR';
|
export const DISPLAY_ASSET_ERROR = 'DISPLAY_ASSET_ERROR';
|
||||||
|
|
||||||
/ new
|
// new
|
||||||
export const NEW_ASSET_REQUEST = 'NEW_ASSET_REQUEST';
|
export const NEW_ASSET_REQUEST = 'NEW_ASSET_REQUEST';
|
||||||
export const ASSET_REQUEST_ADD = 'ASSET_REQUEST_ADD';
|
export const ASSET_REQUEST_ADD = 'ASSET_REQUEST_ADD';
|
||||||
export const ASSET_ADD = 'ASSET_ADD';
|
export const SHOW_NEW_ASSET = 'SHOW_NEW_ASSET';
|
||||||
|
export const SHOW_ASSET_CLEAR = 'SHOW_ASSET_CLEAR';
|
||||||
|
|
|
@ -1,36 +1,39 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
import { newAssetRequest, updateAssetClaimData, updateShowAssetError } from 'actions/show';
|
import { newAssetRequest, updateRequestError, showNewAsset, updateShowAsset, clearShowAsset } from 'actions/show';
|
||||||
|
|
||||||
const mapStateToProps = ({ show }) => {
|
const mapStateToProps = ({ show }) => {
|
||||||
return {
|
return {
|
||||||
// new
|
// new
|
||||||
request : show.assetRequest,
|
requestName : show.assetRequest.name,
|
||||||
assetRequests: show.assetRequests,
|
requestModifier : show.assetRequest.modifier,
|
||||||
extension : show.assetRequest.extension,
|
requestExtension: show.assetRequest.extension,
|
||||||
|
assetRequests : show.assetRequests,
|
||||||
|
assets : show.assets,
|
||||||
// old
|
// old
|
||||||
error : show.showAsset.error,
|
error : show.showAsset.error,
|
||||||
claimData: show.showAsset.claimData,
|
name : show.showAsset.name,
|
||||||
|
claimData : show.showAsset.claimData,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
// new
|
// new
|
||||||
onNewAssetRequest (name, modifier) {
|
onNewRequest: (id, name, modifier) => {
|
||||||
dispatch(newAssetRequest(name, modifier));
|
dispatch(newAssetRequest(id, name, modifier));
|
||||||
},
|
},
|
||||||
// old
|
onRequestError: (error) => {
|
||||||
onShowAssetError: (error) => {
|
dispatch(updateRequestError(error, null, null));
|
||||||
dispatch(updateShowAssetError(error));
|
|
||||||
},
|
},
|
||||||
onAssetClaimDataUpdate: (claimData, shortId) => {
|
onShowNewAsset: (id, name, claimId) => {
|
||||||
dispatch(updateAssetClaimData(claimData, shortId));
|
dispatch(showNewAsset(id, name, claimId));
|
||||||
dispatch(updateShowAssetError(null)); // clear any errors
|
|
||||||
},
|
},
|
||||||
onAssetClaimDataClear: () => {
|
onShowExistingAsset: (id, error, name, claimId, shortId, claimData) => {
|
||||||
dispatch(updateAssetClaimData(null, null));
|
dispatch(updateShowAsset(id, error, name, claimId, shortId, claimData));
|
||||||
dispatch(updateShowAssetError(null)); // clear any errors
|
},
|
||||||
|
onLeaveShowAsset: () => {
|
||||||
|
dispatch(clearShowAsset()); // clear any errors
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,53 +2,80 @@ import React from 'react';
|
||||||
import ErrorPage from 'components/ErrorPage';
|
import ErrorPage from 'components/ErrorPage';
|
||||||
import ShowAssetLite from 'components/ShowAssetLite';
|
import ShowAssetLite from 'components/ShowAssetLite';
|
||||||
import ShowAssetDetails from 'components/ShowAssetDetails';
|
import ShowAssetDetails from 'components/ShowAssetDetails';
|
||||||
import request from 'utils/request';
|
|
||||||
|
|
||||||
function buildIdFromModifierObject (modifier) {
|
function buildIdFromModifierObject (name, modifier) {
|
||||||
if (modifier) {
|
if (modifier) {
|
||||||
if (modifier.channel.name) {
|
if (modifier.channel.name) {
|
||||||
return `${modifier.channel.name}#${modifier.channel.id}`;
|
return `${name}#${modifier.channel.name}#${modifier.channel.id}`;
|
||||||
}
|
}
|
||||||
return modifier.id;
|
return `${name}#${modifier.id}`;
|
||||||
}
|
}
|
||||||
return '';
|
return `${name}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildIdFromNameAndClaimId (name, claimId) {
|
||||||
|
return `${name}#${claimId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ShowAsset extends React.Component {
|
class ShowAsset extends React.Component {
|
||||||
constructor (props) {
|
|
||||||
super(props);
|
|
||||||
this.getLongClaimId = this.getLongClaimId.bind(this);
|
|
||||||
this.getClaimData = this.getClaimData.bind(this);
|
|
||||||
}
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { request: { name, modifier }, assetRequests } = this.props;
|
const { requestName, requestModifier, assetRequests } = this.props;
|
||||||
const id = buildIdFromModifierObject(modifier);
|
const id = buildIdFromModifierObject(requestName, requestModifier);
|
||||||
// check to see if we have this asset
|
// check to see if we have this asset
|
||||||
if (assetRequests[id]) {
|
if (assetRequests[id]) { // case: the assetRequest exists
|
||||||
// case: the assetRequest exists
|
const request = assetRequests[id];
|
||||||
this.props.onNewAssetRequest(id, name, modifier); // request the long id and update the store with a new asset request record.
|
this.onRepeatRequest(id, request);
|
||||||
} else {
|
} else { // case: the asset request does not exist
|
||||||
// case: the asset request does not exist
|
this.onNewRequest(id, requestName, requestModifier);
|
||||||
this.onRepeatAssetRequest(name, modifier); // get the asset request record...?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onRepeatAssetRequest (id, modifier, assetRequests) {
|
componentWillReceiveProps (nextProps) {
|
||||||
// get the results of the existing asset request
|
if (nextProps.assetRequests !== this.props.assetRequests) {
|
||||||
const {error, claimId} = assetRequests[id];
|
console.log('assetRequests updated:');
|
||||||
console.log(`results form past request ${id}:`, error, claimId);
|
const { requestName, requestModifier, assetRequests } = nextProps;
|
||||||
|
const id = buildIdFromModifierObject(requestName, requestModifier);
|
||||||
|
// if the component received new assetRequests, check again to see if the current request matches one
|
||||||
|
if (assetRequests[id]) { // case: the assetRequest exists
|
||||||
|
const request = assetRequests[id];
|
||||||
|
this.onRepeatRequest(id, request);
|
||||||
|
} else { // case: the asset request does not exist
|
||||||
|
this.onNewRequest(id, requestName, requestModifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onNewRequest (id, requestName, requestModifier) {
|
||||||
|
console.log('new request');
|
||||||
|
this.props.onNewRequest(id, requestName, requestModifier);
|
||||||
|
}
|
||||||
|
onRepeatRequest (requestId, request) {
|
||||||
|
console.log('repeat request');
|
||||||
|
const { assets } = this.props;
|
||||||
|
const { error: requestError, name, claimId } = request;
|
||||||
|
const assetId = buildIdFromNameAndClaimId(name, claimId);
|
||||||
|
// if error, return and update state with error
|
||||||
|
if (requestError) {
|
||||||
|
return this.props.onRequestError(requestError);
|
||||||
|
}
|
||||||
|
// update the show asset data in the store
|
||||||
|
if (assets[assetId]) { // case: the asset data already exists
|
||||||
|
let { error, name, claimId, shortId, claimData } = assets[assetId];
|
||||||
|
this.props.onShowExistingAsset(assetId, error, name, claimId, shortId, claimData);
|
||||||
|
} else { // case: the asset data does not exist yet
|
||||||
|
this.props.onShowNewAsset(assetId, name, claimId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
this.props.onAssetClaimDataClear();
|
this.props.onLeaveShowAsset();
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const { error, claimData, extension } = this.props;
|
const { error, name, requestExtension } = this.props;
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
<ErrorPage error={error}/>
|
<ErrorPage error={error}/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (claimData) {
|
if (name) {
|
||||||
if (extension) {
|
if (requestExtension) {
|
||||||
return (
|
return (
|
||||||
<ShowAssetLite />
|
<ShowAssetLite />
|
||||||
);
|
);
|
||||||
|
|
|
@ -38,8 +38,10 @@ const initialState = {
|
||||||
},
|
},
|
||||||
showAsset: {
|
showAsset: {
|
||||||
error : null,
|
error : null,
|
||||||
claimData: null,
|
name : null,
|
||||||
|
claimId : null,
|
||||||
shortId : null,
|
shortId : null,
|
||||||
|
claimData: null,
|
||||||
},
|
},
|
||||||
displayAsset: {
|
displayAsset: {
|
||||||
error : null,
|
error : null,
|
||||||
|
@ -48,28 +50,16 @@ const initialState = {
|
||||||
channelRequests: {},
|
channelRequests: {},
|
||||||
assetRequests : {},
|
assetRequests : {},
|
||||||
channels : {},
|
channels : {},
|
||||||
assets : {},
|
assets : {}, // same schema as showAsset
|
||||||
};
|
};
|
||||||
|
|
||||||
/* asset request schema:
|
/* asset request schema:
|
||||||
name#someidfrommodifier: {
|
name#someidfrommodifier: {
|
||||||
error : null
|
error : null,
|
||||||
|
name : null,
|
||||||
claimId: null,
|
claimId: null,
|
||||||
} */
|
} */
|
||||||
|
|
||||||
/* asset schema:
|
|
||||||
name#claimId: {
|
|
||||||
error : null,
|
|
||||||
name : null,
|
|
||||||
claimId : null,
|
|
||||||
claimData: null,
|
|
||||||
shortId : null,
|
|
||||||
display : {
|
|
||||||
error : null,
|
|
||||||
status: null,
|
|
||||||
}
|
|
||||||
} */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Reducers describe how the application's state changes in response to actions
|
Reducers describe how the application's state changes in response to actions
|
||||||
*/
|
*/
|
||||||
|
@ -119,19 +109,14 @@ export default function (state = initialState, action) {
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
// show asset cases
|
// show asset cases
|
||||||
case actions.SHOW_ASSET_ERROR:
|
// case actions.SHOW_ASSET_UPDATE:
|
||||||
return Object.assign({}, state, {
|
// return Object.assign({}, state, {
|
||||||
showAsset: Object.assign({}, state.showAsset, {
|
// showAsset: Object.assign({}, state.showAsset, {
|
||||||
error: action.data,
|
// error : action.data.error,
|
||||||
}),
|
// claimData: action.data.claimData,
|
||||||
});
|
// shortId : action.data.shortId,
|
||||||
case actions.ASSET_CLAIM_DATA_UPDATE:
|
// }),
|
||||||
return Object.assign({}, state, {
|
// });
|
||||||
showAsset: Object.assign({}, state.showAsset, {
|
|
||||||
claimData: action.data.data,
|
|
||||||
shortId : action.data.shortId,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
// display asset cases
|
// display asset cases
|
||||||
case actions.FILE_AVAILABILITY_UPDATE:
|
case actions.FILE_AVAILABILITY_UPDATE:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
|
@ -152,17 +137,40 @@ export default function (state = initialState, action) {
|
||||||
assetRequests: Object.assign({}, state.assets, {
|
assetRequests: Object.assign({}, state.assets, {
|
||||||
[action.data.id]: {
|
[action.data.id]: {
|
||||||
error : action.data.error,
|
error : action.data.error,
|
||||||
|
name : action.data.name,
|
||||||
claimId: action.data.claimId,
|
claimId: action.data.claimId,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
case actions.SHOW_ASSET_UPDATE:
|
||||||
// case actions.ASSET_ADD:
|
return Object.assign({}, state, {
|
||||||
// return Object.assign({}, state, {
|
assets: Object.assign({}, state.assets, {
|
||||||
// assets: Object.assign({}, state.assets, {
|
[action.data.id]: {
|
||||||
// [`${action.data.name}#${action.data.claimId}`]: action.data,
|
error : action.data.error,
|
||||||
// }),
|
name : action.data.name,
|
||||||
// });
|
claimId : action.data.claimId,
|
||||||
|
shortId : action.data.shortId,
|
||||||
|
claimData: action.data.claimData,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
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,
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
case actions.SHOW_ASSET_CLEAR:
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
showAsset: Object.assign({}, state.showAsset, {
|
||||||
|
error : null,
|
||||||
|
name : null,
|
||||||
|
claimId : null,
|
||||||
|
shortId : null,
|
||||||
|
claimData: null,
|
||||||
|
}),
|
||||||
|
});
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { all } from 'redux-saga/effects';
|
import { all } from 'redux-saga/effects';
|
||||||
import { watchNewAssetRequest, watchFileIsRequested } from './show';
|
import { watchNewAssetRequest, watchShowNewAsset, watchFileIsRequested } from './show';
|
||||||
|
|
||||||
export default function* rootSaga () {
|
export default function* rootSaga () {
|
||||||
yield all([
|
yield all([
|
||||||
watchNewAssetRequest(),
|
watchNewAssetRequest(),
|
||||||
|
watchShowNewAsset(),
|
||||||
watchFileIsRequested(),
|
watchFileIsRequested(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,62 +1,50 @@
|
||||||
import { call, put, takeLatest } from 'redux-saga/effects';
|
import { call, put, takeLatest } from 'redux-saga/effects';
|
||||||
import * as actions from 'constants/show_action_types';
|
import * as actions from 'constants/show_action_types';
|
||||||
import { addAssetRequest, updateFileAvailability, updateDisplayAssetError } from 'actions/show';
|
import { addAssetRequest, updateShowAsset, updateFileAvailability, updateDisplayAssetError } from 'actions/show';
|
||||||
import { UNAVAILABLE, AVAILABLE } from 'constants/asset_display_states';
|
import { UNAVAILABLE, AVAILABLE } from 'constants/asset_display_states';
|
||||||
import { checkFileAvailability, triggerClaimGet } from 'api/fileApi';
|
import { checkFileAvailability, triggerClaimGet } from 'api/fileApi';
|
||||||
import { getLongClaimId } from 'api/AssetApi';
|
import { getLongClaimId, getShortId, getClaimData } from 'api/AssetApi';
|
||||||
import request from '../utils/request';
|
|
||||||
|
|
||||||
function* newAssetRequest (action) {
|
function* newAssetRequest (action) {
|
||||||
const { id, name, modifier } = action.data;
|
const { id, name, modifier } = action.data;
|
||||||
// get the long claim id
|
|
||||||
let success, message, longId;
|
let success, message, longId;
|
||||||
try {
|
try {
|
||||||
({success, message, data: longId} = yield call(getLongClaimId, name, modifier));
|
({success, message, data: longId} = yield call(getLongClaimId, name, modifier));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('error making getLongClaimId call', error);
|
console.log('error making getLongClaimId call', error);
|
||||||
yield put(addAssetRequest(id, error.message, null));
|
yield put(addAssetRequest(id, error.message, name, null));
|
||||||
}
|
}
|
||||||
// put a new action to update the store with result
|
|
||||||
if (success) {
|
if (success) {
|
||||||
return yield put(addAssetRequest(id, null, longId));
|
return yield put(addAssetRequest(id, null, name, longId));
|
||||||
}
|
}
|
||||||
yield put(addAssetRequest(id, message, null));
|
yield put(addAssetRequest(id, message, name, null));
|
||||||
};
|
};
|
||||||
|
|
||||||
function* getShortId (action) {
|
function* getAssetDataAndShowAsset (action) {
|
||||||
const { longId, name } = action.data;
|
const {id, name, claimId} = action.data;
|
||||||
const url = `/api/claim/short-id/${longId}/${name}`;
|
// if no error, get short Id
|
||||||
return new Promise((resolve, reject) => {
|
let success, message, shortId;
|
||||||
request(url)
|
try {
|
||||||
.then(({ success, message, data }) => {
|
({success, message, data: shortId} = yield call(getShortId, name, claimId));
|
||||||
console.log('get short claim id response:', data);
|
} catch (error) {
|
||||||
if (!success) {
|
return yield put(updateShowAsset(id, error.message, null, null, null)); // add with error
|
||||||
reject(message);
|
}
|
||||||
}
|
if (!success) {
|
||||||
resolve(data);
|
return yield put(updateShowAsset(id, message, null, null, null)); // add with error
|
||||||
})
|
}
|
||||||
.catch((error) => {
|
// if no error, get claim data
|
||||||
reject(error.message);
|
success = null;
|
||||||
});
|
let claimData;
|
||||||
});
|
try {
|
||||||
}
|
({success, message, data: claimData} = yield call(getClaimData, name, claimId));
|
||||||
|
} catch (error) {
|
||||||
function* getClaimData (action) {
|
return yield put(updateShowAsset(id, error.message, null, null, null)); // add with error
|
||||||
const { claimName, claimId } = action.data;
|
}
|
||||||
return new Promise((resolve, reject) => {
|
if (!success) {
|
||||||
const url = `/api/claim/data/${claimName}/${claimId}`;
|
return yield put(updateShowAsset(id, message, null, null, null)); // add with error
|
||||||
return request(url)
|
}
|
||||||
.then(({ success, message }) => {
|
// if both are successfull, add to asset list and select for showing
|
||||||
console.log('get claim data response:', message);
|
yield put(updateShowAsset(id, null, name, claimId, shortId, claimData));
|
||||||
if (!success) {
|
|
||||||
reject(message);
|
|
||||||
}
|
|
||||||
resolve(message);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
reject(error.message);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function* retriveFile (action) {
|
function* retriveFile (action) {
|
||||||
|
@ -95,6 +83,10 @@ export function* watchNewAssetRequest () {
|
||||||
yield takeLatest(actions.NEW_ASSET_REQUEST, newAssetRequest);
|
yield takeLatest(actions.NEW_ASSET_REQUEST, newAssetRequest);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function* watchShowNewAsset () {
|
||||||
|
yield takeLatest(actions.SHOW_NEW_ASSET, getAssetDataAndShowAsset);
|
||||||
|
};
|
||||||
|
|
||||||
export function* watchFileIsRequested () {
|
export function* watchFileIsRequested () {
|
||||||
yield takeLatest(actions.FILE_REQUESTED, retriveFile);
|
yield takeLatest(actions.FILE_REQUESTED, retriveFile);
|
||||||
};
|
};
|
||||||
|
|
|
@ -207,7 +207,7 @@ module.exports = (app) => {
|
||||||
res.status(200).json({success: false, message: error.message});
|
res.status(200).json({success: false, message: error.message});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
app.get('/api/claim/long-id', ({ ip, originalUrl, body, params }, res) => {
|
app.post('/api/claim/long-id', ({ ip, originalUrl, body, params }, res) => {
|
||||||
logger.debug('body:', body);
|
logger.debug('body:', body);
|
||||||
const channelName = body.channelName;
|
const channelName = body.channelName;
|
||||||
const channelClaimId = body.channelClaimId;
|
const channelClaimId = body.channelClaimId;
|
||||||
|
@ -237,7 +237,7 @@ module.exports = (app) => {
|
||||||
if (!claimInfo) {
|
if (!claimInfo) {
|
||||||
return res.status(200).json({success: false, message: 'No claim could be found'});
|
return res.status(200).json({success: false, message: 'No claim could be found'});
|
||||||
}
|
}
|
||||||
res.status(200).json({success: true, message: claimInfo});
|
res.status(200).json({success: true, data: claimInfo});
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
logger.error('api error getting long claim id', error);
|
logger.error('api error getting long claim id', error);
|
||||||
|
|
Loading…
Reference in a new issue