chained show asset to new asset request
This commit is contained in:
parent
1a47296e24
commit
61d5feee82
3 changed files with 24 additions and 21 deletions
|
@ -50,11 +50,13 @@ class ShowAsset extends React.Component {
|
||||||
// update the showAsset data in the store
|
// update the showAsset data in the store
|
||||||
const { assets } = this.props;
|
const { assets } = this.props;
|
||||||
const assetId = `a#${name}#${claimId}`;
|
const assetId = `a#${name}#${claimId}`;
|
||||||
if (assets[assetId]) { // case: the asset data already exists
|
const existingAssetRecord = assets[assetId];
|
||||||
let { error: assetError, name, claimId, shortId, claimData } = assets[assetId];
|
if (existingAssetRecord) { // case: the asset data already exists
|
||||||
|
let { error: assetError, name, claimId, shortId, claimData } = existingAssetRecord;
|
||||||
this.props.onShowExistingAsset(assetId, assetError, name, claimId, shortId, claimData);
|
this.props.onShowExistingAsset(assetId, assetError, name, claimId, shortId, claimData);
|
||||||
} else { // case: the asset data does not exist yet
|
} else { // case: the asset data does not exist yet
|
||||||
this.props.onShowNewAsset(assetId, name, claimId);
|
console.log('error: there should be an existing record');
|
||||||
|
// this.props.onShowNewAsset(assetId, name, claimId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
|
|
|
@ -38,7 +38,7 @@ class ShowChannel extends React.Component {
|
||||||
console.log('new request');
|
console.log('new request');
|
||||||
this.props.onNewChannelRequest(requestId, requestName, requestChannelId);
|
this.props.onNewChannelRequest(requestId, requestName, requestChannelId);
|
||||||
}
|
}
|
||||||
onRepeatChannelRequest ({ id, error, name, claimId }) {
|
onRepeatChannelRequest ({ id, error, data: { channelName, longChannelClaimId} }) {
|
||||||
// if error, return and update state with error
|
// if error, return and update state with error
|
||||||
if (error) {
|
if (error) {
|
||||||
return this.props.onRequestError(error);
|
return this.props.onRequestError(error);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
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, updateShowAsset, addChannelRequest, updateShowChannel, updateFileAvailability, updateDisplayAssetError } from 'actions/show';
|
import { addAssetRequest, updateShowAsset, showNewAsset, addChannelRequest, updateShowChannel, 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, getShortId, getClaimData } from 'api/assetApi';
|
import { getLongClaimId, getShortId, getClaimData } from 'api/assetApi';
|
||||||
|
@ -15,26 +15,12 @@ function* newAssetRequest (action) {
|
||||||
yield put(addAssetRequest(id, error.message, name, null));
|
yield put(addAssetRequest(id, error.message, name, null));
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
return yield put(addAssetRequest(id, null, name, longId));
|
yield put(addAssetRequest(id, null, name, longId));
|
||||||
|
return yield put(showNewAsset(id, name, longId));
|
||||||
}
|
}
|
||||||
yield put(addAssetRequest(id, message, name, null));
|
yield put(addAssetRequest(id, message, name, null));
|
||||||
};
|
};
|
||||||
|
|
||||||
function* newChannelRequest (action) {
|
|
||||||
const { id, name, channelId } = action.data;
|
|
||||||
let success, message, data;
|
|
||||||
try {
|
|
||||||
({success, message, data} = yield call(getChannelData, name, channelId));
|
|
||||||
} catch (error) {
|
|
||||||
yield put(addChannelRequest(id, error.message, null));
|
|
||||||
}
|
|
||||||
if (success) {
|
|
||||||
console.log('api/channel/data/ response:', data);
|
|
||||||
return yield put(addChannelRequest(id, null, data));
|
|
||||||
}
|
|
||||||
yield put(addChannelRequest(id, message, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
function* getAssetDataAndShowAsset (action) {
|
function* getAssetDataAndShowAsset (action) {
|
||||||
const {id, name, claimId} = action.data;
|
const {id, name, claimId} = action.data;
|
||||||
// if no error, get short Id
|
// if no error, get short Id
|
||||||
|
@ -94,6 +80,21 @@ function* retriveFile (action) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function* newChannelRequest (action) {
|
||||||
|
const { id, name, channelId } = action.data;
|
||||||
|
let success, message, data;
|
||||||
|
try {
|
||||||
|
({success, message, data} = yield call(getChannelData, name, channelId));
|
||||||
|
} catch (error) {
|
||||||
|
yield put(addChannelRequest(id, error.message, null));
|
||||||
|
}
|
||||||
|
if (success) {
|
||||||
|
console.log('api/channel/data/ response:', data);
|
||||||
|
return yield put(addChannelRequest(id, null, data));
|
||||||
|
}
|
||||||
|
yield put(addChannelRequest(id, message, null));
|
||||||
|
}
|
||||||
|
|
||||||
export function* watchNewAssetRequest () {
|
export function* watchNewAssetRequest () {
|
||||||
yield takeLatest(actions.ASSET_REQUEST_NEW, newAssetRequest);
|
yield takeLatest(actions.ASSET_REQUEST_NEW, newAssetRequest);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue