updated channel request storage
This commit is contained in:
parent
2363fe8717
commit
c38eeb9850
8 changed files with 40 additions and 55 deletions
|
@ -39,7 +39,7 @@ export function updateRequestWithAssetRequest (name, id, channelName, channelId,
|
|||
|
||||
export function newAssetRequest (id, name, modifier) {
|
||||
return {
|
||||
type: actions.NEW_ASSET_REQUEST,
|
||||
type: actions.ASSET_REQUEST_NEW,
|
||||
data: { id, name, modifier },
|
||||
};
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ export function addAssetRequest (id, error, name, claimId) {
|
|||
|
||||
export function showNewAsset (id, name, claimId) {
|
||||
return {
|
||||
type: actions.SHOW_NEW_ASSET,
|
||||
type: actions.SHOW_ASSET_NEW,
|
||||
data: { id, name, claimId },
|
||||
};
|
||||
};
|
||||
|
@ -82,29 +82,23 @@ export function newChannelRequest (id, name, channelId) {
|
|||
};
|
||||
};
|
||||
|
||||
export function addChannelRequest (id, error, name, data) {
|
||||
export function addChannelRequest (id, error, data) {
|
||||
return {
|
||||
type: actions.CHANNEL_REQUEST_ADD,
|
||||
data: { id, error, name, data },
|
||||
data: { id, error, data },
|
||||
};
|
||||
}
|
||||
|
||||
// show a channel
|
||||
|
||||
// export function updateShowChannelError (error) {
|
||||
// return {
|
||||
// type: actions.SHOW_CHANNEL_ERROR,
|
||||
// data: error,
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// export function updateChannelData (name, longId, shortId) {
|
||||
// return {
|
||||
// type: actions.CHANNEL_DATA_UPDATE,
|
||||
// data: { name, longId, shortId },
|
||||
// };
|
||||
// };
|
||||
//
|
||||
export function showNewChannel (name, longId, shortId) {
|
||||
|
||||
};
|
||||
|
||||
export function updateShowChannel (name, longId, shortId) {
|
||||
|
||||
};
|
||||
|
||||
export function clearShowChannel () {
|
||||
return {
|
||||
type: actions.SHOW_CHANNEL_CLEAR,
|
||||
|
|
|
@ -14,10 +14,10 @@ export const FILE_AVAILABILITY_UPDATE = 'FILE_AVAILABILITY_UPDATE';
|
|||
export const DISPLAY_ASSET_ERROR = 'DISPLAY_ASSET_ERROR';
|
||||
|
||||
// new
|
||||
export const NEW_ASSET_REQUEST = 'NEW_ASSET_REQUEST';
|
||||
export const ASSET_REQUEST_NEW = 'ASSET_REQUEST_NEW';
|
||||
export const ASSET_REQUEST_ADD = 'ASSET_REQUEST_ADD';
|
||||
|
||||
export const SHOW_NEW_ASSET = 'SHOW_NEW_ASSET';
|
||||
export const SHOW_ASSET_NEW = 'SHOW_ASSET_NEW';
|
||||
export const SHOW_ASSET_CLEAR = 'SHOW_ASSET_CLEAR';
|
||||
|
||||
export const NEW_CHANNEL_REQUEST = 'NEW_CHANNEL_REQUEST';
|
||||
|
|
|
@ -4,17 +4,18 @@ import { newAssetRequest, updateRequestError, showNewAsset, updateShowAsset, cle
|
|||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
return {
|
||||
// new
|
||||
// request
|
||||
requestId : show.request.id,
|
||||
requestName : show.request.data.name,
|
||||
requestModifier : show.request.data.modifier,
|
||||
requestExtension: show.request.data.extension,
|
||||
assetRequests : show.assetRequests,
|
||||
assets : show.assets,
|
||||
// old
|
||||
// show asset
|
||||
error : show.showAsset.error,
|
||||
name : show.showAsset.name,
|
||||
claimData : show.showAsset.claimData,
|
||||
// test
|
||||
showAsset : show.assets[show.request.id],
|
||||
};
|
||||
};
|
||||
|
|
|
@ -4,12 +4,14 @@ import View from './view';
|
|||
|
||||
const mapStateToProps = ({ show }) => {
|
||||
return {
|
||||
// request
|
||||
requestId : show.request.id,
|
||||
requestType : show.request.type,
|
||||
requestChannelName: show.request.data.name,
|
||||
requestChannelId : show.request.data.id,
|
||||
requestList : show.channelRequests,
|
||||
channels : show.channels,
|
||||
// show channel
|
||||
error : show.showChannel.error,
|
||||
name : show.showChannel.channelData.name,
|
||||
shortId : show.showChannel.channelData.shortId,
|
||||
|
|
|
@ -13,31 +13,28 @@ function channelNameOrIdChanged (nextProps, props) {
|
|||
return (nextProps.requestChannelName !== props.requestChannelName || nextProps.requestChannelName !== props.requestChannelName);
|
||||
}
|
||||
|
||||
function existingRequest (requestId, requestList) {
|
||||
return requestList[requestId];
|
||||
}
|
||||
|
||||
class ShowChannel extends React.Component {
|
||||
componentDidMount () {
|
||||
console.log('showchannel did mount');
|
||||
const {requestId, requestName, requestChannelId, requestList} = this.props;
|
||||
if (existingRequest(requestId, requestList)) {
|
||||
// const validRequest = existingRequest(requestId, requestList);
|
||||
// this.onRepeatChannelRequest(validRequest);
|
||||
const {requestId, requestChannelName, requestChannelId, requestList} = this.props;
|
||||
const existingRequest = requestList[requestId];
|
||||
if (existingRequest) {
|
||||
console.log('we got a repeat channel request on an unmounted ShowChannel component');
|
||||
this.onRepeatChannelRequest(existingRequest);
|
||||
} else {
|
||||
this.onNewChannelRequest(requestId, requestName, requestChannelId);
|
||||
this.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
|
||||
}
|
||||
}
|
||||
componentWillReceiveProps (nextProps) {
|
||||
console.log('showchannel will receive new props');
|
||||
if (requestIsAChannelRequest(nextProps) && channelNameOrIdChanged(nextProps, this.props)) {
|
||||
const {requestId, requestList} = nextProps;
|
||||
if (existingRequest(requestId, requestList)) {
|
||||
const request = requestList[requestId];
|
||||
this.onRepeatChannelRequest(request);
|
||||
const {requestId, requestChannelName, requestChannelId, requestList} = nextProps;
|
||||
const existingRequest = requestList[requestId];
|
||||
if (existingRequest) {
|
||||
this.onRepeatChannelRequest(existingRequest);
|
||||
} else {
|
||||
console.log('we got a new channel request on a mounted ShowChannel component');
|
||||
this.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -122,27 +122,16 @@ export default function (state = initialState, action) {
|
|||
// request a channel
|
||||
case actions.CHANNEL_REQUEST_ADD:
|
||||
return Object.assign({}, state, {
|
||||
channelRequests: Object.assign({}, state.assetRequests, {
|
||||
channelRequests: Object.assign({}, state.channelRequests, {
|
||||
[action.data.id]: {
|
||||
error: action.data.error,
|
||||
name : action.data.name,
|
||||
data : action.data.data,
|
||||
},
|
||||
}),
|
||||
});
|
||||
// show a channel
|
||||
// case actions.SHOW_CHANNEL_ERROR:
|
||||
// return Object.assign({}, state, {
|
||||
// showChannel: Object.assign({}, state.showChannel, {
|
||||
// error: action.data,
|
||||
// }),
|
||||
// });
|
||||
// case actions.CHANNEL_DATA_UPDATE:
|
||||
// return Object.assign({}, state, {
|
||||
// showChannel: Object.assign({}, state.showChannel, {
|
||||
// channelData: action.data,
|
||||
// }),
|
||||
// });
|
||||
// case actions.SHOW_CHANNEL_NEW:
|
||||
// case actions.SHOW_CHANNEL_UPDATE:
|
||||
case actions.SHOW_CHANNEL_CLEAR:
|
||||
return Object.assign({}, state, {
|
||||
showChannel: {
|
||||
|
@ -158,6 +147,7 @@ export default function (state = initialState, action) {
|
|||
totalPages : null,
|
||||
totalClaims: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
// display an asset
|
||||
case actions.FILE_AVAILABILITY_UPDATE:
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { all } from 'redux-saga/effects';
|
||||
import { watchNewAssetRequest, watchShowNewAsset, watchFileIsRequested } from './show';
|
||||
import { watchNewAssetRequest, watchShowNewAsset, watchNewChannelRequest, watchFileIsRequested } from './show';
|
||||
|
||||
export default function* rootSaga () {
|
||||
yield all([
|
||||
watchNewAssetRequest(),
|
||||
watchShowNewAsset(),
|
||||
watchNewChannelRequest(),
|
||||
watchFileIsRequested(),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@ function* newChannelRequest (action) {
|
|||
try {
|
||||
({success, message, data} = yield call(getChannelData, name, channelId));
|
||||
} catch (error) {
|
||||
yield put(addChannelRequest(id, error.message, name, null));
|
||||
yield put(addChannelRequest(id, error.message, null));
|
||||
}
|
||||
if (success) {
|
||||
console.log('api/channel/data/ response:', data);
|
||||
return yield put(addChannelRequest(id, null, name, data));
|
||||
return yield put(addChannelRequest(id, null, data));
|
||||
}
|
||||
yield put(addChannelRequest(id, message, name, null));
|
||||
yield put(addChannelRequest(id, message, null));
|
||||
}
|
||||
|
||||
function* getAssetDataAndShowAsset (action) {
|
||||
|
@ -95,7 +95,7 @@ function* retriveFile (action) {
|
|||
};
|
||||
|
||||
export function* watchNewAssetRequest () {
|
||||
yield takeLatest(actions.NEW_ASSET_REQUEST, newAssetRequest);
|
||||
yield takeLatest(actions.ASSET_REQUEST_NEW, newAssetRequest);
|
||||
};
|
||||
|
||||
export function* watchNewChannelRequest () {
|
||||
|
@ -103,7 +103,7 @@ export function* watchNewChannelRequest () {
|
|||
};
|
||||
|
||||
export function* watchShowNewAsset () {
|
||||
yield takeLatest(actions.SHOW_NEW_ASSET, getAssetDataAndShowAsset);
|
||||
yield takeLatest(actions.SHOW_ASSET_NEW, getAssetDataAndShowAsset);
|
||||
};
|
||||
|
||||
export function* watchFileIsRequested () {
|
||||
|
|
Loading…
Reference in a new issue