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