converted channel display to use id
This commit is contained in:
parent
c96c4d1fbd
commit
75b5981e01
8 changed files with 43 additions and 68 deletions
|
@ -109,10 +109,10 @@ export function showNewChannel (channelData) {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function updateShowChannel (error, name, shortId, longId, claimsData) {
|
export function updateShowChannel (error, id) {
|
||||||
return {
|
return {
|
||||||
type: actions.SHOW_CHANNEL_UPDATE,
|
type: actions.SHOW_CHANNEL_UPDATE,
|
||||||
data: { error, name, shortId, longId, claimsData },
|
data: { error, id },
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2,15 +2,9 @@ import { connect } from 'react-redux';
|
||||||
import { } from 'actions/show';
|
import { } from 'actions/show';
|
||||||
import View from './view';
|
import View from './view';
|
||||||
|
|
||||||
const mapStateToProps = ({ show : { showChannel: { error, channelData, claimsData } } }) => {
|
const mapStateToProps = ({ show }) => {
|
||||||
return {
|
return {
|
||||||
error : error,
|
channel: show.channelList[show.showChannel.id],
|
||||||
name : channelData.name,
|
|
||||||
longId : channelData.longId,
|
|
||||||
claims : claimsData.claims,
|
|
||||||
currentPage: claimsData.currentPage,
|
|
||||||
totalPages : claimsData.totalPages,
|
|
||||||
totalClaims: claimsData.totalClaims,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ class ChannelClaimsDisplay extends React.Component {
|
||||||
this.showNewPage(nextPage);
|
this.showNewPage(nextPage);
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const { error, claims, currentPage, totalPages } = this.props;
|
const { channel: { error, claimsData: { claims, currentPage, totalPages } } } = this.props;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{error ? (
|
{error ? (
|
||||||
|
|
|
@ -13,25 +13,26 @@ const mapStateToProps = ({ show }) => {
|
||||||
channelList : show.channelList,
|
channelList : show.channelList,
|
||||||
// show channel
|
// show channel
|
||||||
error : show.showChannel.error,
|
error : show.showChannel.error,
|
||||||
name : show.showChannel.channelData.name,
|
id : show.showChannel.id,
|
||||||
shortId : show.showChannel.channelData.shortId,
|
channel : show.channelList[show.showChannel.id],
|
||||||
longId : show.showChannel.channelData.longId,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
|
// request
|
||||||
onNewChannelRequest (id, name, channelId) {
|
onNewChannelRequest (id, name, channelId) {
|
||||||
dispatch(newChannelRequest(id, name, channelId));
|
dispatch(newChannelRequest(id, name, channelId));
|
||||||
},
|
},
|
||||||
onRequestError: (error) => {
|
onRequestError: (error) => {
|
||||||
dispatch(updateRequestError(error, null, null));
|
dispatch(updateRequestError(error, null, null));
|
||||||
},
|
},
|
||||||
|
// show channel
|
||||||
onShowNewChannel: (channelData) => {
|
onShowNewChannel: (channelData) => {
|
||||||
dispatch(showNewChannel(channelData));
|
dispatch(showNewChannel(channelData));
|
||||||
},
|
},
|
||||||
onShowExistingChannel: (error, name, shortId, longId, claimsData) => {
|
onShowExistingChannel: (id) => {
|
||||||
dispatch(updateShowChannel(error, name, shortId, longId, claimsData));
|
dispatch(updateShowChannel(null, id));
|
||||||
},
|
},
|
||||||
onShowChannelClear: () => {
|
onShowChannelClear: () => {
|
||||||
dispatch(clearShowChannel());
|
dispatch(clearShowChannel());
|
||||||
|
|
|
@ -49,7 +49,7 @@ class ShowChannel extends React.Component {
|
||||||
const channelRecordId = `c#${channelData.name}#${channelData.longId}`;
|
const channelRecordId = `c#${channelData.name}#${channelData.longId}`;
|
||||||
const existingChannel = channelList[channelRecordId];
|
const existingChannel = channelList[channelRecordId];
|
||||||
if (existingChannel) {
|
if (existingChannel) {
|
||||||
this.showExistingChannel(existingChannel);
|
this.showExistingChannel(channelRecordId);
|
||||||
} else {
|
} else {
|
||||||
this.showNewChannel(channelData);
|
this.showNewChannel(channelData);
|
||||||
}
|
}
|
||||||
|
@ -57,20 +57,21 @@ class ShowChannel extends React.Component {
|
||||||
showNewChannel (channelData) {
|
showNewChannel (channelData) {
|
||||||
this.props.onShowNewChannel(channelData);
|
this.props.onShowNewChannel(channelData);
|
||||||
};
|
};
|
||||||
showExistingChannel (existingChannel) {
|
showExistingChannel (channelRecordId) {
|
||||||
const { error, channelData: {name, shortId, longId}, claimsData } = existingChannel;
|
this.props.onShowExistingChannel(channelRecordId);
|
||||||
this.props.onShowExistingChannel(error, name, shortId, longId, claimsData);
|
|
||||||
};
|
};
|
||||||
componentWillUnmount () {
|
componentWillUnmount () {
|
||||||
this.props.onShowChannelClear();
|
this.props.onShowChannelClear();
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
const { error, name, longId, shortId } = this.props;
|
const { error, channel } = this.props;
|
||||||
if (error) {
|
if (error) {
|
||||||
return (
|
return (
|
||||||
<ErrorPage error={error}/>
|
<ErrorPage error={error}/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
if (channel) {
|
||||||
|
const { channelData: { name, longId, shortId } } = channel;
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<NavBar/>
|
<NavBar/>
|
||||||
|
@ -86,6 +87,10 @@ class ShowChannel extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<ErrorPage error={'loading channel data...'}/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,17 +11,7 @@ const initialState = {
|
||||||
},
|
},
|
||||||
showChannel: {
|
showChannel: {
|
||||||
error: null,
|
error: null,
|
||||||
channelData: {
|
id : null,
|
||||||
name : null,
|
|
||||||
shortId: null,
|
|
||||||
longId : null,
|
|
||||||
},
|
|
||||||
claimsData: {
|
|
||||||
claims : null,
|
|
||||||
currentPage: null,
|
|
||||||
totalPages : null,
|
|
||||||
totalClaims: null,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
showAsset: {
|
showAsset: {
|
||||||
error: null,
|
error: null,
|
||||||
|
@ -133,29 +123,14 @@ export default function (state = initialState, action) {
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
showChannel: {
|
showChannel: {
|
||||||
error: action.data.error,
|
error: action.data.error,
|
||||||
channelData: {
|
id : action.data.id,
|
||||||
name : action.data.name,
|
|
||||||
shortId: action.data.shortId,
|
|
||||||
longId : action.data.longId,
|
|
||||||
},
|
|
||||||
claimsData: action.data.claimsData,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
case actions.SHOW_CHANNEL_CLEAR:
|
case actions.SHOW_CHANNEL_CLEAR:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
showChannel: {
|
showChannel: {
|
||||||
error: null,
|
error: null,
|
||||||
channelData: {
|
id : null,
|
||||||
name : null,
|
|
||||||
shortId: null,
|
|
||||||
longId : null,
|
|
||||||
},
|
|
||||||
claimsData: {
|
|
||||||
claims : null,
|
|
||||||
currentPage: null,
|
|
||||||
totalPages : null,
|
|
||||||
totalClaims: null,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
// add channel to channel list
|
// add channel to channel list
|
||||||
|
|
|
@ -26,8 +26,8 @@ function* getAssetDataAndShowAsset (action) {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return yield put(updateShowAsset(message, null));
|
return yield put(updateShowAsset(message, null));
|
||||||
}
|
}
|
||||||
yield put(updateShowAsset(null, id));
|
|
||||||
yield put(upsertAssetToAssetList(id, null, name, claimId, shortId, claimData));
|
yield put(upsertAssetToAssetList(id, null, name, claimId, shortId, claimData));
|
||||||
|
yield put(updateShowAsset(null, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* watchShowNewAsset () {
|
export function* watchShowNewAsset () {
|
||||||
|
|
|
@ -9,14 +9,14 @@ 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));
|
return yield put(updateShowChannel(error.message, null));
|
||||||
}
|
}
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return yield put(updateShowChannel(message, name, shortId, longId));
|
return yield put(updateShowChannel(message, null));
|
||||||
}
|
}
|
||||||
yield put(updateShowChannel(null, name, shortId, longId, claimsData));
|
|
||||||
const channelData = {name, shortId, longId};
|
const channelData = {name, shortId, longId};
|
||||||
yield put(addNewChannelToChannelList(id, null, channelData, claimsData));
|
yield put(addNewChannelToChannelList(id, null, channelData, claimsData));
|
||||||
|
yield put(updateShowChannel(null, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* watchShowNewChannel () {
|
export function* watchShowNewChannel () {
|
||||||
|
|
Loading…
Reference in a new issue