fixed request error for broken requests

This commit is contained in:
bill bittner 2018-02-08 13:39:14 -08:00
parent c4042ecea9
commit eb2f7ac7fc

View file

@ -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, showNewAsset, updateShowAsset, addAssetToAssetList, addChannelRequest, showNewChannel, updateShowChannel, addNewChannelToChannelList, updateFileAvailability, updateDisplayAssetError } from 'actions/show'; import { addAssetRequest, updateRequestError, showNewAsset, updateShowAsset, addAssetToAssetList, addChannelRequest, showNewChannel, updateShowChannel, addNewChannelToChannelList, 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';
@ -12,14 +12,16 @@ function* newAssetRequest (action) {
try { try {
({success, message, data: longId} = yield call(getLongClaimId, name, modifier)); ({success, message, data: longId} = yield call(getLongClaimId, name, modifier));
} catch (error) { } catch (error) {
yield put(addAssetRequest(id, error.message, name, null)); // yield put(addAssetRequest(id, error.message, name, null));
return yield put(updateRequestError(error.message));
}
if (!success) {
// yield put(addAssetRequest(id, message, name, null));
return yield put(updateRequestError(message));
} }
if (success) {
yield put(addAssetRequest(id, null, name, longId)); yield put(addAssetRequest(id, null, name, longId));
const newAssetId = `a#${name}#${longId}`; // note move to action const newAssetId = `a#${name}#${longId}`; // note: move to action
return yield put(showNewAsset(newAssetId, name, longId)); yield put(showNewAsset(newAssetId, name, longId));
}
yield put(addAssetRequest(id, message, name, null));
}; };
function* getAssetDataAndShowAsset (action) { function* getAssetDataAndShowAsset (action) {
@ -29,12 +31,12 @@ function* getAssetDataAndShowAsset (action) {
try { try {
({success, message, data: shortId} = yield call(getShortId, name, claimId)); ({success, message, data: shortId} = yield call(getShortId, name, claimId));
} catch (error) { } catch (error) {
// yield put(addAssetToAssetList());
return yield put(updateShowAsset(error.message, name, claimId)); return yield put(updateShowAsset(error.message, name, claimId));
// yield put(addAssetToAssetList(arg1, arg2));
} }
if (!success) { if (!success) {
// yield put(addAssetToAssetList());
return yield put(updateShowAsset(message, name, claimId)); return yield put(updateShowAsset(message, name, claimId));
// yield put(addAssetToAssetList(arg1, arg2));
} }
// if no error, get claim data // if no error, get claim data
success = null; success = null;
@ -42,12 +44,12 @@ function* getAssetDataAndShowAsset (action) {
try { try {
({success, message, data: claimData} = yield call(getClaimData, name, claimId)); ({success, message, data: claimData} = yield call(getClaimData, name, claimId));
} catch (error) { } catch (error) {
// yield put(addAssetToAssetList());
return yield put(updateShowAsset(error.message, name, claimId)); return yield put(updateShowAsset(error.message, name, claimId));
// yield put(addAssetToAssetList(arg1, arg2));
} }
if (!success) { if (!success) {
// yield put(addAssetToAssetList());
return yield put(updateShowAsset(message, name, claimId)); return yield put(updateShowAsset(message, name, claimId));
// yield put(addAssetToAssetList(arg1, arg2));
} }
// if both are successfull, add to asset list and select for showing // if both are successfull, add to asset list and select for showing
yield put(updateShowAsset(null, name, claimId, shortId, claimData)); yield put(updateShowAsset(null, name, claimId, shortId, claimData));
@ -92,10 +94,12 @@ function* newChannelRequest (action) {
try { try {
({success, message, data} = yield call(getChannelData, name, channelId)); ({success, message, data} = yield call(getChannelData, name, channelId));
} catch (error) { } catch (error) {
return yield put(addChannelRequest(id, error.message, null, null, null)); // return yield put(addChannelRequest(id, error.message, null, null, null));
return yield put(updateRequestError(message));
} }
if (!success) { if (!success) {
return yield put(addChannelRequest(id, message, null, null, null)); // return yield put(addChannelRequest(id, message, null, null, null));
return yield put(updateRequestError(message));
} }
const { longChannelClaimId: longId, shortChannelClaimId: shortId } = data; const { longChannelClaimId: longId, shortChannelClaimId: shortId } = data;
yield put(addChannelRequest(id, null, name, longId, shortId)); yield put(addChannelRequest(id, null, name, longId, shortId));
@ -110,12 +114,12 @@ function* getNewChannelDataAndShowChannel (action) {
try { try {
({ success, message, data: claimsData } = yield call(getChannelClaims, name, longId, 1)); ({ success, message, data: claimsData } = yield call(getChannelClaims, name, longId, 1));
} catch (error) { } catch (error) {
return yield put(updateShowChannel(error.message, name, shortId, longId));
// yield put(addNewChannelToChannelList(id, error.message, null, null)); // yield put(addNewChannelToChannelList(id, error.message, null, null));
return yield put(updateShowChannel(error.message, name, shortId, longId));
} }
if (!success) { if (!success) {
return yield put(updateShowChannel(message, name, shortId, longId));
// yield put(addNewChannelToChannelList(id, message, null, null)); // yield put(addNewChannelToChannelList(id, message, null, null));
return yield put(updateShowChannel(message, name, shortId, longId));
} }
yield put(updateShowChannel(null, name, shortId, longId, claimsData)); yield put(updateShowChannel(null, name, shortId, longId, claimsData));
const channelData = {name, shortId, longId}; const channelData = {name, shortId, longId};