moved channel selection logic to mapStateToProps

This commit is contained in:
bill bittner 2018-02-12 18:18:56 -08:00
parent afe95916c1
commit 249b6c6f0f
19 changed files with 198 additions and 327 deletions

View file

@ -61,24 +61,11 @@ export function showNewAsset (name, claimId) {
};
};
export function updateShowAsset (error, id) {
return {
type: actions.SHOW_ASSET_UPDATE,
data: { error, id },
};
};
export function clearShowAsset () {
return {
type: actions.SHOW_ASSET_CLEAR,
};
};
// add asset to asset list
export function upsertAssetToAssetList (id, error, name, claimId, shortId, claimData) {
export function addAssetToAssetList (id, error, name, claimId, shortId, claimData) {
return {
type: actions.ASSET_LIST_UPSERT,
type: actions.ASSET_LIST_ADD,
data: { id, error, name, claimId, shortId, claimData },
};
}
@ -101,33 +88,29 @@ export function addChannelRequest (id, error, name, longId, shortId) {
// show a channel
export function showNewChannel (channelData) {
const id = `c#${channelData.name}#${channelData.longId}`; // move to the action
export function showNewChannel (name, shortId, longId) {
const id = `c#${name}#${longId}`; // move to the action
return {
type: actions.SHOW_CHANNEL_NEW,
data: { id, channelData },
data: { id, name, shortId, longId },
};
};
export function updateShowChannel (error, id) {
return {
type: actions.SHOW_CHANNEL_UPDATE,
data: { error, id },
};
};
// add channels to channel list
export function clearShowChannel () {
export function addNewChannelToChannelList (id, name, shortId, longId, claimsData) {
return {
type: actions.SHOW_CHANNEL_CLEAR,
type: actions.CHANNEL_LIST_ADD,
data: { id, name, shortId, longId, claimsData },
};
};
// update channel data
export function updateChannelClaimsAsync (channelListId, name, longId, page) {
export function updateChannelClaimsAsync (channelKey, name, longId, page) {
return {
type: actions.CHANNEL_LIST_CLAIMS_UPDATE_ASYNC,
data: {channelListId, name, longId, page},
data: {channelKey, name, longId, page},
};
};
@ -138,15 +121,6 @@ export function updateChannelClaims (channelListId, claimsData) {
};
};
// add channels to channel list
export function addNewChannelToChannelList (id, error, channelData, claimsData) {
return {
type: actions.CHANNEL_LIST_ADD,
data: { id, error, channelData, claimsData },
};
};
// display a file
export function fileRequested (name, claimId) {

View file

@ -3,11 +3,18 @@ import View from './view';
import { fileRequested } from 'actions/show';
const mapStateToProps = ({ show }) => {
return {
error : show.displayAsset.error,
status : show.displayAsset.status,
asset : show.assetList[show.showAsset.id],
let props = {
error : show.displayAsset.error,
status: show.displayAsset.status,
};
// select asset info
const existingRequest = show.assetRequests[show.request.id];
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`;
const existingAsset = show.assetList[assetKey];
if (existingAsset) {
props['asset'] = existingAsset;
};
return props;
};
const mapDispatchToProps = dispatch => {

View file

@ -2,9 +2,15 @@ import { connect } from 'react-redux';
import View from './view';
const mapStateToProps = ({ show }) => {
return {
asset: show.assetList[show.showAsset.id],
let props = {};
// select asset info
const request = show.assetRequests[show.request.id];
const assetKey = `a#${request.name}#${request.claimId}`;
const asset = show.assetList[assetKey];
if (asset) {
props['asset'] = asset;
};
return props;
};
export default connect(mapStateToProps, null)(View);

View file

@ -2,9 +2,15 @@ import { connect } from 'react-redux';
import View from './view';
const mapStateToProps = ({ show }) => {
return {
title: show.assetList[show.showAsset.id].claimData.title,
let props = {};
// select title
const existingRequest = show.assetRequests[show.request.id];
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`;
const existingAsset = show.assetList[assetKey];
if (existingAsset) {
props['title'] = existingAsset.claimData.title;
};
return props;
};
export default connect(mapStateToProps, null)(View);

View file

@ -1,10 +1,4 @@
import { connect } from 'react-redux';
import View from './view';
const mapStateToProps = ({ show }) => {
return {
asset: show.assetList[show.showAsset.id],
};
};
export default connect(mapStateToProps, null)(View);
export default connect(null, null)(View);

View file

@ -1,5 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import NavBar from 'containers/NavBar';
import AssetTitle from 'components/AssetTitle';
import AssetDisplay from 'components/AssetDisplay';
@ -7,11 +6,9 @@ import AssetInfo from 'components/AssetInfo';
class ShowAssetDetails extends React.Component {
render () {
const { asset } = this.props;
return (
<div>
<NavBar/>
{asset &&
<div className="row row--tall row--padded">
<div className="column column--10">
<AssetTitle />
@ -32,8 +29,4 @@ class ShowAssetDetails extends React.Component {
}
};
ShowAssetDetails.propTypes = {
error: PropTypes.string,
};
export default ShowAssetDetails;

View file

@ -2,9 +2,16 @@ import { connect } from 'react-redux';
import View from './view';
const mapStateToProps = ({ show }) => {
return {
asset: show.assetList[show.showAsset.id],
let props = {};
// select name and claim id
const existingRequest = show.assetRequests[show.request.id];
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`;
const existingAsset = show.assetList[assetKey];
if (existingAsset) {
props['name'] = existingAsset.name;
props['claimId'] = existingAsset.claimId;
};
return props;
};
export default connect(mapStateToProps, null)(View);

View file

@ -4,7 +4,7 @@ import AssetDisplay from 'components/AssetDisplay';
class ShowLite extends React.Component {
render () {
const { asset: { name, claimId } } = this.props;
const { name, claimId } = this.props;
return (
<div className="row row--tall flex-container--column flex-container--center-center">
{ (name && claimId) &&

View file

@ -8,10 +8,7 @@ export const ASSET_REQUEST_NEW = 'ASSET_REQUEST_NEW';
export const ASSET_REQUEST_ADD = 'ASSET_REQUEST_ADD';
export const SHOW_ASSET_NEW = 'SHOW_ASSET_NEW';
export const SHOW_ASSET_UPDATE = 'SHOW_ASSET_UPDATE';
export const SHOW_ASSET_CLEAR = 'SHOW_ASSET_CLEAR';
export const ASSET_LIST_UPSERT = `ASSET_LIST_UPSERT`;
export const ASSET_LIST_ADD = `ASSET_LIST_ADD`;
// channel request actions
export const CHANNEL_REQUEST_NEW = 'CHANNEL_REQUEST_NEW';

View file

@ -3,16 +3,23 @@ import { updateChannelClaimsAsync } from 'actions/show';
import View from './view';
const mapStateToProps = ({ show }) => {
return {
showChannelId: show.showChannel.id,
channel : show.channelList[show.showChannel.id],
let props = {};
// select channel key
const request = show.channelRequests[show.request.id];
const channelKey = `c#${request.name}#${request.longId}`;
props['channelKey'] = channelKey;
// select channel claims
const channel = show.channelList[channelKey];
if (channel) {
props['channel'] = channel;
};
return props;
};
const mapDispatchToProps = dispatch => {
return {
onChannelPageUpdate: (showChannelId, name, longId, page) => {
dispatch(updateChannelClaimsAsync(showChannelId, name, longId, page));
onChannelPageUpdate: (channelKey, name, longId, page) => {
dispatch(updateChannelClaimsAsync(channelKey, name, longId, page));
},
};
};

View file

@ -18,43 +18,32 @@ class ChannelClaimsDisplay extends React.Component {
this.showNewPage(nextPage);
}
showNewPage (page) {
const { showChannelId, channel: { channelData: { name, longId } } } = this.props;
console.log(`update claims data on channel ${showChannelId} with new page ${page}`);
this.props.onChannelPageUpdate(showChannelId, name, longId, page);
const { channelKey, channel: { name, longId } } = this.props;
this.props.onChannelPageUpdate(channelKey, name, longId, page);
}
render () {
const { channel: { error, claimsData: { claims, currentPage, totalPages } } } = this.props;
const { channel: { claimsData: { claims, currentPage, totalPages } } } = this.props;
return (
<div>
{error ? (
<div className="row">
<div className="column column--10">
<p>{error}</p>
</div>
</div>
) : (
<div className="row row--tall">
{claims &&
<div>
{claims.map((claim, index) => <AssetPreview
name={claim.name}
claimId={claim.claimId}
fileExt={claim.fileExt}
contentType={claim.contentType}
key={`${claim.name}-${index}`}
/>)}
<div>
{(currentPage > 1) &&
<button className={'button--secondary'} onClick={this.showPreviousResultsPage}>Previous Page</button>
}
{(currentPage < totalPages) &&
<button className={'button--secondary'} onClick={this.showNextResultsPage}>Next Page</button>
}
</div>
</div>
<div className="row row--tall">
{claims &&
<div>
{claims.map((claim, index) => <AssetPreview
name={claim.name}
claimId={claim.claimId}
fileExt={claim.fileExt}
contentType={claim.contentType}
key={`${claim.name}-${index}`}
/>)}
<div>
{(currentPage > 1) &&
<button className={'button--secondary'} onClick={this.showPreviousResultsPage}>Previous Page</button>
}
{(currentPage < totalPages) &&
<button className={'button--secondary'} onClick={this.showNextResultsPage}>Next Page</button>
}
</div>
)}
</div>
}
</div>
);
}

View file

@ -1,20 +1,27 @@
import { connect } from 'react-redux';
import View from './view';
import { newAssetRequest, updateRequestError, showNewAsset, updateShowAsset, clearShowAsset } from 'actions/show';
import { newAssetRequest, showNewAsset } from 'actions/show';
const mapStateToProps = ({ show }) => {
return {
// request
requestId : show.request.id,
requestName : show.request.data.name,
requestModifier : show.request.data.modifier,
requestExtension: show.request.data.extension,
assetRequests : show.assetRequests,
assetList : show.assetList,
// show asset
error : show.showAsset.error,
id : show.showAsset.id,
let props = {};
props['requestType'] = show.request.type;
props['requestId'] = show.request.id;
props['requestName'] = show.request.data.name;
props['requestModifier'] = show.request.data.modifier;
props['requestExtension'] = show.request.data.extension;
// select request
const existingRequest = show.assetRequests[show.request.id];
if (existingRequest) {
props['existingRequest'] = existingRequest;
// select asset info
const assetKey = `a#${existingRequest.name}#${existingRequest.claimId}`; // note: just store this in the request
const existingAsset = show.assetList[assetKey];
if (existingAsset) {
console.log('existing asset found', existingAsset);
props['asset'] = existingAsset;
};
};
return props;
};
const mapDispatchToProps = dispatch => {
@ -23,19 +30,10 @@ const mapDispatchToProps = dispatch => {
onNewRequest: (id, name, modifier) => {
dispatch(newAssetRequest(id, name, modifier));
},
onRequestError: (error) => {
dispatch(updateRequestError(error, null, null));
},
// show asset
onShowNewAsset: (name, claimId) => {
dispatch(showNewAsset(name, claimId));
},
onShowExistingAsset: (assetId) => {
dispatch(updateShowAsset(null, assetId));
},
onLeaveShowAsset: () => {
dispatch(clearShowAsset()); // clear any errors
},
};
};

View file

@ -9,83 +9,40 @@ function requestIsAnAssetRequest ({ requestType }) {
return requestType === ASSET;
}
function requestIsNewRequest (nextProps, props) {
return (nextProps.requestId !== props.requestId);
}
class ShowAsset extends React.Component {
componentDidMount () {
const { requestId, requestName, requestModifier, assetRequests } = this.props;
const existingRequest = assetRequests[requestId];
if (existingRequest) { // case: the assetRequest exists
this.onRepeatRequest(existingRequest);
} else { // case: the asset request does not exist
this.onNewRequest(requestId, requestName, requestModifier);
}
const { asset, existingRequest, requestId, requestName, requestModifier } = this.props;
if (!existingRequest) { // case: the asset request does not exist
return this.props.onNewRequest(requestId, requestName, requestModifier);
};
if (!asset) { // case: the asset request does not exist
const { name, claimId } = existingRequest;
return this.props.onShowNewAsset(name, claimId);
};
}
componentWillReceiveProps (nextProps) {
// case where componentDidMount triggered new props
if (requestIsAnAssetRequest(nextProps) && requestIsNewRequest(nextProps, this.props)) {
const { requestId, requestName, requestModifier, assetRequests } = nextProps;
const existingRequest = assetRequests[requestId];
if (existingRequest) { // case: the assetRequest exists
this.onRepeatRequest(existingRequest);
} else { // case: the asset request does not exist
this.onNewRequest(requestId, requestName, requestModifier);
}
} else {
console.log('ShowAsset receiving new props -> request.id did not update', nextProps);
if (requestIsAnAssetRequest(nextProps)) {
const { asset, existingRequest, requestId, requestName, requestModifier } = nextProps;
if (!existingRequest) {
return this.props.onNewRequest(requestId, requestName, requestModifier);
};
if (!asset) {
const { name, claimId } = existingRequest;
return this.props.onShowNewAsset(name, claimId);
};
}
}
onNewRequest (id, requestName, requestModifier) {
console.log('new request');
this.props.onNewRequest(id, requestName, requestModifier);
}
onRepeatRequest ({ error, name, claimId }) {
console.log('repeat request');
// if error, return and update state with error
if (error) {
return this.props.onRequestError(error);
}
// update the showAsset data in the store
const { assetList } = this.props;
const assetId = `a#${name}#${claimId}`;
const existingAssetRecord = assetList[assetId];
if (existingAssetRecord) { // case: the asset data already exists
this.showExistingAsset(assetId);
} else { // case: the asset data does not exist yet
this.showNewAsset(name, claimId);
}
}
showNewAsset (name, claimId) {
this.props.onShowNewAsset(name, claimId);
}
showExistingAsset (assetId) {
this.props.onShowExistingAsset(assetId);
}
componentWillUnmount () {
this.props.onLeaveShowAsset();
}
render () {
const { error, id, requestExtension } = this.props;
if (error) {
return (
<ErrorPage error={error}/>
);
}
if (id) { // direct requests are passing because name is present so it just goes
const {asset, requestExtension} = this.props;
if (asset) {
if (requestExtension) {
return (
<ShowAssetLite />
);
} else {
return (
<ShowAssetDetails />
);
return <ShowAssetLite/>;
}
};
return <ShowAssetDetails/>;
}
;
return (
<div> </div>
<ErrorPage error={'loading asset data...'}/>
);
}
};

View file

@ -1,41 +1,38 @@
import { connect } from 'react-redux';
import {newChannelRequest, updateRequestError, showNewChannel, updateShowChannel, clearShowChannel} from 'actions/show';
import { newChannelRequest, showNewChannel } from 'actions/show';
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,
channelList : show.channelList,
// show channel
error : show.showChannel.error,
id : show.showChannel.id,
channel : show.channelList[show.showChannel.id],
};
let props = {};
props['requestId'] = show.request.id;
props['requestType'] = show.request.type;
props['requestChannelName'] = show.request.data.name;
props['requestChannelId'] = show.request.data.id;
// select request
const existingRequest = show.channelRequests[show.request.id];
if (existingRequest) {
props['existingRequest'] = existingRequest;
console.log('existing channel request found', existingRequest);
// select channel info
const channelKey = `c#${existingRequest.name}#${existingRequest.longId}`;
const channel = show.channelList[channelKey];
if (channel) {
props['channel'] = channel;
};
}
return props;
};
const mapDispatchToProps = dispatch => {
return {
// request
onNewChannelRequest (id, name, channelId) {
dispatch(newChannelRequest(id, name, channelId));
},
onRequestError: (error) => {
dispatch(updateRequestError(error, null, null));
onNewChannelRequest (requestId, requestChannelName, requestChannelId) {
dispatch(newChannelRequest(requestId, requestChannelName, requestChannelId));
},
// show channel
onShowNewChannel: (channelData) => {
dispatch(showNewChannel(channelData));
},
onShowExistingChannel: (id) => {
dispatch(updateShowChannel(null, id));
},
onShowChannelClear: () => {
dispatch(clearShowChannel());
onShowNewChannel: (name, shortId, longId) => {
dispatch(showNewChannel(name, shortId, longId));
},
};
};

View file

@ -9,69 +9,33 @@ function requestIsAChannelRequest ({ requestType }) {
return requestType === CHANNEL;
}
function requestIsNewRequest (nextProps, props) {
return (nextProps.requestId !== props.requestId);
}
class ShowChannel extends React.Component {
componentDidMount () {
const {requestId, requestChannelName, requestChannelId, requestList, channelList} = this.props;
const existingRequest = requestList[requestId];
if (existingRequest) {
this.onRepeatChannelRequest(existingRequest, channelList);
} else {
this.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
const { existingRequest, channel, requestId, requestChannelName, requestChannelId } = this.props;
if (!existingRequest) {
return this.props.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
}
if (!channel) {
const { name, shortId, longId } = existingRequest;
return this.props.onShowNewChannel(name, shortId, longId);
}
}
componentWillReceiveProps (nextProps) {
if (requestIsAChannelRequest(nextProps) && requestIsNewRequest(nextProps, this.props)) {
const {requestId, requestChannelName, requestChannelId, requestList, channelList} = nextProps;
const existingRequest = requestList[requestId];
if (existingRequest) {
this.onRepeatChannelRequest(existingRequest, channelList);
} else {
this.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
if (requestIsAChannelRequest(nextProps)) {
const { existingRequest, channel, requestId, requestChannelName, requestChannelId } = nextProps;
if (!existingRequest) {
return this.props.onNewChannelRequest(requestId, requestChannelName, requestChannelId);
}
if (!channel) {
const { name, shortId, longId } = existingRequest;
return this.props.onShowNewChannel(name, shortId, longId);
}
} else {
console.log('ShowChannel receiving new props -> request.id did not update', nextProps);
};
}
onNewChannelRequest (requestId, requestName, requestChannelId) {
console.log('new request');
this.props.onNewChannelRequest(requestId, requestName, requestChannelId);
}
onRepeatChannelRequest ({ error, channelData }, channelList) {
// if error, return and update state with error
if (error) {
return this.props.onRequestError(error);
}
// check if the channel data is present or not
const channelRecordId = `c#${channelData.name}#${channelData.longId}`;
const existingChannel = channelList[channelRecordId];
if (existingChannel) {
this.showExistingChannel(channelRecordId);
} else {
this.showNewChannel(channelData);
}
}
showNewChannel (channelData) {
this.props.onShowNewChannel(channelData);
};
showExistingChannel (channelRecordId) {
this.props.onShowExistingChannel(channelRecordId);
};
componentWillUnmount () {
this.props.onShowChannelClear();
}
render () {
const { error, channel } = this.props;
if (error) {
return (
<ErrorPage error={error}/>
);
};
const { channel } = this.props;
if (channel) {
const { channelData: { name, longId, shortId } } = channel;
const { name, longId, shortId } = channel;
return (
<div>
<NavBar/>
@ -82,7 +46,7 @@ class ShowChannel extends React.Component {
<p className={'fine-print'}>short channel id: {shortId ? shortId : 'loading...'}</p>
</div>
<div className="column column--10">
{(name && longId) && <ChannelClaimsDisplay />}
<ChannelClaimsDisplay />
</div>
</div>
</div>

View file

@ -9,14 +9,6 @@ const initialState = {
data : null,
requestId: null,
},
showChannel: {
error: null,
id : null,
},
showAsset: {
error: null,
id : null,
},
displayAsset: {
error : null,
status: LOCAL_CHECK,
@ -24,7 +16,7 @@ const initialState = {
channelRequests: {},
channelList : {},
assetRequests : {},
assetList : {}, // same schema as showAsset
assetList : {},
};
export default function (state = initialState, action) {
@ -72,23 +64,8 @@ export default function (state = initialState, action) {
},
}),
});
// show an asset
case actions.SHOW_ASSET_UPDATE:
return Object.assign({}, state, {
showAsset: Object.assign({}, state.showAsset, {
error: action.data.error,
id : action.data.id,
}),
});
case actions.SHOW_ASSET_CLEAR:
return Object.assign({}, state, {
showAsset: Object.assign({}, state.showAsset, {
error: null,
id : null,
}),
});
// add asset to asset list
case actions.ASSET_LIST_UPSERT:
case actions.ASSET_LIST_ADD:
return Object.assign({}, state, {
assetList: Object.assign({}, state.assetList, {
[action.data.id]: {
@ -105,12 +82,10 @@ export default function (state = initialState, action) {
return Object.assign({}, state, {
channelRequests: Object.assign({}, state.channelRequests, {
[action.data.id]: {
error : action.data.error,
channelData: {
name : action.data.name,
longId : action.data.longId,
shortId: action.data.shortId,
},
error : action.data.error,
name : action.data.name,
longId : action.data.longId,
shortId: action.data.shortId,
},
}),
});
@ -134,9 +109,10 @@ export default function (state = initialState, action) {
return Object.assign({}, state, {
channelList: Object.assign({}, state.channelList, {
[action.data.id]: {
error : action.data.error,
channelData: action.data.channelData,
claimsData : action.data.claimsData,
name : action.data.name,
longId : action.data.longId,
shortId : action.data.shortId,
claimsData: action.data.claimsData,
},
}),
});

View file

@ -26,7 +26,7 @@ function* newChannelRequest (action) {
({success, message, data} = yield call(getChannelData, name, channelId));
} catch (error) {
// return yield put(addChannelRequest(id, error.message, null, null, null));
return yield put(updateRequestError(message));
return yield put(updateRequestError(error.message));
}
if (!success) {
// return yield put(addChannelRequest(id, message, null, null, null));
@ -34,8 +34,7 @@ function* newChannelRequest (action) {
}
const { longChannelClaimId: longId, shortChannelClaimId: shortId } = data;
yield put(addChannelRequest(id, null, name, longId, shortId));
const channelData = {name, longId, shortId};
yield put(showNewChannel(channelData));
yield put(showNewChannel(name, shortId, longId));
}
export function* watchNewAssetRequest () {

View file

@ -1,6 +1,6 @@
import { call, put, takeLatest } from 'redux-saga/effects';
import * as actions from 'constants/show_action_types';
import { updateShowAsset, upsertAssetToAssetList } from 'actions/show';
import { updateRequestError, addAssetToAssetList } from 'actions/show';
import { getShortId, getClaimData } from 'api/assetApi';
function* getAssetDataAndShowAsset (action) {
@ -10,10 +10,10 @@ function* getAssetDataAndShowAsset (action) {
try {
({success, message, data: shortId} = yield call(getShortId, name, claimId));
} catch (error) {
return yield put(updateShowAsset(error.message, null));
return yield put(updateRequestError(error.message));
}
if (!success) {
return yield put(updateShowAsset(message, null));
return yield put(updateRequestError(message));
}
// if no error, get claim data
success = null;
@ -21,13 +21,13 @@ function* getAssetDataAndShowAsset (action) {
try {
({success, message, data: claimData} = yield call(getClaimData, name, claimId));
} catch (error) {
return yield put(updateShowAsset(error.message, null));
return yield put(updateRequestError(error.message));
}
if (!success) {
return yield put(updateShowAsset(message, null));
return yield put(updateRequestError(message));
}
yield put(upsertAssetToAssetList(id, null, name, claimId, shortId, claimData));
yield put(updateShowAsset(null, id));
yield put(addAssetToAssetList(id, null, name, claimId, shortId, claimData));
yield put(updateRequestError(null));
}
export function* watchShowNewAsset () {

View file

@ -1,22 +1,22 @@
import { call, put, takeLatest } from 'redux-saga/effects';
import * as actions from 'constants/show_action_types';
import { updateShowChannel, addNewChannelToChannelList, updateChannelClaims } from 'actions/show';
import { updateRequestError, addNewChannelToChannelList, updateChannelClaims } from 'actions/show';
import { getChannelClaims } from 'api/channelApi';
function* getChannelClaimsAndShowChannel (action) {
const { id, channelData: {name, shortId, longId} } = action.data;
const { id, name, shortId, longId } = action.data;
console.log('getchannelclaimsandshowchannel', id, name, shortId, longId);
let success, message, claimsData;
try {
({ success, message, data: claimsData } = yield call(getChannelClaims, name, longId, 1));
} catch (error) {
return yield put(updateShowChannel(error.message, null));
return yield put(updateRequestError(error.message));
}
if (!success) {
return yield put(updateShowChannel(message, null));
return yield put(updateRequestError(message));
}
const channelData = {name, shortId, longId};
yield put(addNewChannelToChannelList(id, null, channelData, claimsData));
yield put(updateShowChannel(null, id));
yield put(addNewChannelToChannelList(id, name, shortId, longId, claimsData));
yield put(updateRequestError(null));
}
export function* watchShowNewChannel () {
@ -24,17 +24,17 @@ export function* watchShowNewChannel () {
};
function* getNewClaimsAndUpdateClaimsList (action) {
const { channelListId, name, longId, page } = action.data;
const { channelKey, name, longId, page } = action.data;
let success, message, claimsData;
try {
({ success, message, data: claimsData } = yield call(getChannelClaims, name, longId, page));
} catch (error) {
return yield put(updateShowChannel(error.message, null));
return yield put(updateRequestError(error.message));
}
if (!success) {
return yield put(updateShowChannel(message, null));
return yield put(updateRequestError(message));
}
yield put(updateChannelClaims(channelListId, claimsData));
yield put(updateChannelClaims(channelKey, claimsData));
}
export function* watchShowNewChannelClaimsRequest () {