consolidated requests into one list
This commit is contained in:
parent
4a2fbb402f
commit
0cecc84dde
12 changed files with 52 additions and 58 deletions
|
@ -39,15 +39,22 @@ export function onNewAssetRequest (name, id, channelName, channelId, extension)
|
|||
};
|
||||
};
|
||||
|
||||
// asset actions
|
||||
|
||||
export function addRequestToAssetRequests (id, error, name, claimId) {
|
||||
export function addRequestToPreviousRequests (id, error, key) {
|
||||
return {
|
||||
type: actions.ASSET_REQUEST_SUCCESS,
|
||||
data: { id, error, name, claimId },
|
||||
type: actions.PREVIOUS_REQUEST_ADD,
|
||||
data: { id, error, key },
|
||||
};
|
||||
};
|
||||
|
||||
// asset actions
|
||||
|
||||
// export function addRequestToAssetRequests (id, error, name, claimId) {
|
||||
// return {
|
||||
// type: actions.ASSET_REQUEST_ADD,
|
||||
// data: { id, error, name, claimId },
|
||||
// };
|
||||
// };
|
||||
|
||||
export function addAssetToAssetList (id, error, name, claimId, shortId, claimData) {
|
||||
return {
|
||||
type: actions.ASSET_ADD,
|
||||
|
@ -57,12 +64,12 @@ export function addAssetToAssetList (id, error, name, claimId, shortId, claimDat
|
|||
|
||||
// channel actions
|
||||
|
||||
export function addRequestToChannelRequests (id, error, name, longId, shortId) {
|
||||
return {
|
||||
type: actions.CHANNEL_REQUEST_ADD,
|
||||
data: { id, error, name, longId, shortId },
|
||||
};
|
||||
};
|
||||
// export function addRequestToChannelRequests (id, error, name, longId, shortId) {
|
||||
// return {
|
||||
// type: actions.CHANNEL_REQUEST_ADD,
|
||||
// data: { id, error, name, longId, shortId },
|
||||
// };
|
||||
// };
|
||||
|
||||
export function addNewChannelToChannelList (id, name, shortId, longId, claimsData) {
|
||||
return {
|
||||
|
|
|
@ -7,8 +7,8 @@ const mapStateToProps = ({ show }) => {
|
|||
const error = show.displayAsset.error;
|
||||
const status = show.displayAsset.status;
|
||||
// select asset
|
||||
const request = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${request.name}#${request.claimId}`;
|
||||
const request = show.previousRequests[show.request.id];
|
||||
const assetKey = request.key;
|
||||
const asset = show.assetList[assetKey];
|
||||
// return props
|
||||
return {
|
||||
|
|
|
@ -3,8 +3,8 @@ import View from './view';
|
|||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
// select asset
|
||||
const request = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${request.name}#${request.claimId}`;
|
||||
const request = show.previousRequests[show.request.id];
|
||||
const assetKey = request.key;
|
||||
const asset = show.assetList[assetKey];
|
||||
// return props
|
||||
return {
|
||||
|
|
|
@ -3,8 +3,8 @@ import View from './view';
|
|||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
// select title
|
||||
const request = show.assetRequests[show.request.id];
|
||||
const assetKey = `a#${request.name}#${request.claimId}`;
|
||||
const request = show.previousRequests[show.request.id];
|
||||
const assetKey = request.key;
|
||||
const asset = show.assetList[assetKey];
|
||||
let title;
|
||||
if (asset) {
|
||||
|
|
|
@ -7,10 +7,10 @@ const mapStateToProps = ({ show }) => {
|
|||
const requestId = show.request.id;
|
||||
// select asset info
|
||||
let asset;
|
||||
const previousRequest = show.assetRequests[requestId] || null;
|
||||
const request = show.previousRequests[requestId] || null;
|
||||
const assetList = show.assetList;
|
||||
if (previousRequest) {
|
||||
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`; // note: just store this in the request
|
||||
if (request && assetList) {
|
||||
const assetKey = request.key; // note: just store this in the request
|
||||
asset = assetList[assetKey] || null;
|
||||
};
|
||||
// return props
|
||||
|
|
|
@ -7,11 +7,10 @@ const mapStateToProps = ({ show }) => {
|
|||
const requestId = show.request.id;
|
||||
// select asset info
|
||||
let asset;
|
||||
const previousRequest = show.assetRequests[requestId] || null;
|
||||
console.log('previous request:', previousRequest);
|
||||
const request = show.previousRequests[requestId] || null;
|
||||
const assetList = show.assetList;
|
||||
if (previousRequest) {
|
||||
const assetKey = `a#${previousRequest.name}#${previousRequest.claimId}`; // note: just store this in the request
|
||||
if (request && assetList) {
|
||||
const assetKey = request.key; // note: just store this in the request
|
||||
asset = assetList[assetKey] || null;
|
||||
};
|
||||
// return props
|
||||
|
|
|
@ -5,11 +5,11 @@ const mapStateToProps = ({ show }) => {
|
|||
// select request info
|
||||
const requestId = show.request.id;
|
||||
// select request
|
||||
const previousRequest = show.channelRequests[requestId] || null;
|
||||
const previousRequest = show.previousRequests[requestId] || null;
|
||||
// select channel
|
||||
let channel;
|
||||
if (previousRequest) {
|
||||
const channelKey = `c#${previousRequest.name}#${previousRequest.longId}`;
|
||||
const channelKey = previousRequest.key;
|
||||
channel = show.channelList[channelKey] || null;
|
||||
}
|
||||
return {
|
||||
|
|
|
@ -4,7 +4,7 @@ export const ASSET_REQUEST_NEW = 'ASSET_REQUEST_NEW';
|
|||
export const CHANNEL_REQUEST_NEW = 'CHANNEL_REQUEST_NEW';
|
||||
|
||||
// asset actions
|
||||
export const ASSET_REQUEST_SUCCESS = 'ASSET_REQUEST_SUCCESS';
|
||||
export const PREVIOUS_REQUEST_ADD = 'PREVIOUS_REQUEST_ADD';
|
||||
export const ASSET_ADD = `ASSET_ADD`;
|
||||
|
||||
// channel actions
|
||||
|
|
|
@ -4,8 +4,8 @@ import View from './view';
|
|||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
// select channel key
|
||||
const request = show.channelRequests[show.request.id];
|
||||
const channelKey = `c#${request.name}#${request.longId}`;
|
||||
const request = show.previousRequests[show.request.id];
|
||||
const channelKey = request.key;
|
||||
// select channel claims
|
||||
const channel = show.channelList[channelKey] || null;
|
||||
// return props
|
||||
|
|
|
@ -7,11 +7,10 @@ const initialState = {
|
|||
type : null,
|
||||
id : null,
|
||||
},
|
||||
channelRequests: {},
|
||||
channelList : {},
|
||||
assetRequests : {},
|
||||
assetList : {},
|
||||
displayAsset : {
|
||||
previousRequests: {},
|
||||
channelList : {},
|
||||
assetList : {},
|
||||
displayAsset : {
|
||||
error : null,
|
||||
status: LOCAL_CHECK,
|
||||
},
|
||||
|
@ -34,17 +33,17 @@ export default function (state = initialState, action) {
|
|||
id : action.data.requestId,
|
||||
}),
|
||||
});
|
||||
// asset actions
|
||||
case actions.ASSET_REQUEST_SUCCESS:
|
||||
// store requests
|
||||
case actions.PREVIOUS_REQUEST_ADD:
|
||||
return Object.assign({}, state, {
|
||||
assetRequests: Object.assign({}, state.assetRequests, {
|
||||
previousRequests: Object.assign({}, state.previousRequests, {
|
||||
[action.data.id]: {
|
||||
error : action.data.error,
|
||||
name : action.data.name,
|
||||
claimId: action.data.claimId,
|
||||
error: action.data.error,
|
||||
key : action.data.key,
|
||||
},
|
||||
}),
|
||||
});
|
||||
// asset data
|
||||
case actions.ASSET_ADD:
|
||||
return Object.assign({}, state, {
|
||||
assetList: Object.assign({}, state.assetList, {
|
||||
|
@ -57,18 +56,7 @@ export default function (state = initialState, action) {
|
|||
},
|
||||
}),
|
||||
});
|
||||
// channel actions
|
||||
case actions.CHANNEL_REQUEST_ADD:
|
||||
return Object.assign({}, state, {
|
||||
channelRequests: Object.assign({}, state.channelRequests, {
|
||||
[action.data.id]: {
|
||||
error : action.data.error,
|
||||
name : action.data.name,
|
||||
longId : action.data.longId,
|
||||
shortId: action.data.shortId,
|
||||
},
|
||||
}),
|
||||
});
|
||||
// channel data
|
||||
case actions.CHANNEL_ADD:
|
||||
return Object.assign({}, state, {
|
||||
channelList: Object.assign({}, state.channelList, {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { call, put, takeLatest } from 'redux-saga/effects';
|
||||
import * as actions from 'constants/show_action_types';
|
||||
import { addRequestToAssetRequests, onRequestError, addAssetToAssetList } from 'actions/show';
|
||||
import { addRequestToPreviousRequests, onRequestError, addAssetToAssetList } from 'actions/show';
|
||||
import { getLongClaimId, getShortId, getClaimData } from 'api/assetApi';
|
||||
|
||||
function* newAssetRequest (action) {
|
||||
|
@ -15,7 +15,8 @@ function* newAssetRequest (action) {
|
|||
return yield put(onRequestError(error.message));
|
||||
}
|
||||
// put action to add request to asset request list
|
||||
yield put(addRequestToAssetRequests(requestId, null, name, longId));
|
||||
const assetKey = `a#${name}#${longId}`;
|
||||
yield put(addRequestToPreviousRequests(requestId, null, assetKey));
|
||||
// get short Id
|
||||
console.log(`getting asset short id ${name} ${longId}`);
|
||||
let shortId;
|
||||
|
@ -33,7 +34,6 @@ function* newAssetRequest (action) {
|
|||
return yield put(onRequestError(error.message));
|
||||
}
|
||||
// put action to add asset to asset list
|
||||
const assetKey = `a#${name}#${longId}`;
|
||||
yield put(addAssetToAssetList(assetKey, null, name, longId, shortId, claimData));
|
||||
// clear any errors in request error
|
||||
yield put(onRequestError(null));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { call, put, takeLatest } from 'redux-saga/effects';
|
||||
import * as actions from 'constants/show_action_types';
|
||||
import { addNewChannelToChannelList, addRequestToChannelRequests, onRequestError, updateChannelClaims } from 'actions/show';
|
||||
import { addNewChannelToChannelList, addRequestToPreviousRequests, onRequestError, updateChannelClaims } from 'actions/show';
|
||||
import { getChannelClaims, getChannelData } from 'api/channelApi';
|
||||
|
||||
function* getNewChannelAndUpdateChannelList (action) {
|
||||
|
@ -14,7 +14,8 @@ function* getNewChannelAndUpdateChannelList (action) {
|
|||
return yield put(onRequestError(error.message));
|
||||
}
|
||||
// store the request in the channel requests list
|
||||
yield put(addRequestToChannelRequests(requestId, null, channelName, longId, shortId));
|
||||
const channelKey = `c#${channelName}#${longId}`;
|
||||
yield put(addRequestToPreviousRequests(requestId, null, channelKey));
|
||||
// get channel claims data
|
||||
console.log('getting channel claims data');
|
||||
let claimsData;
|
||||
|
@ -24,7 +25,6 @@ function* getNewChannelAndUpdateChannelList (action) {
|
|||
return yield put(onRequestError(error.message));
|
||||
}
|
||||
// store the channel data in the channel list
|
||||
const channelKey = `c#${channelName}#${longId}`;
|
||||
yield put(addNewChannelToChannelList(channelKey, channelName, shortId, longId, claimsData));
|
||||
// clear any request errors
|
||||
yield put(onRequestError(null));
|
||||
|
|
Loading…
Add table
Reference in a new issue