lbry-desktop/ui/component/channelEdit/index.js

61 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

import { connect } from 'react-redux';
import {
makeSelectTitleForUri,
makeSelectThumbnailForUri,
makeSelectCoverForUri,
makeSelectMetadataItemForUri,
doUpdateChannel,
2020-06-29 21:54:07 +02:00
doCreateChannel,
makeSelectAmountForUri,
makeSelectClaimForUri,
2020-06-21 18:51:06 +02:00
selectUpdateChannelError,
2020-06-22 17:19:55 +02:00
selectUpdatingChannel,
2020-06-29 21:54:07 +02:00
selectCreateChannelError,
selectCreatingChannel,
selectBalance,
doClearChannelErrors,
} from 'lbry-redux';
2020-06-29 21:54:07 +02:00
import { doOpenModal } from 'redux/actions/app';
import { doUpdateBlockListForPublishedChannel } from 'redux/actions/comments';
import { doClaimInitialRewards } from 'redux/actions/rewards';
import { selectIsClaimingInitialRewards, selectHasClaimedInitialRewards } from 'redux/selectors/rewards';
import ChannelForm from './view';
const select = (state, props) => ({
2020-06-29 21:54:07 +02:00
claim: makeSelectClaimForUri(props.uri)(state),
title: makeSelectTitleForUri(props.uri)(state),
2020-07-02 19:39:29 +02:00
thumbnailUrl: makeSelectThumbnailForUri(props.uri)(state),
coverUrl: makeSelectCoverForUri(props.uri)(state),
description: makeSelectMetadataItemForUri(props.uri, 'description')(state),
website: makeSelectMetadataItemForUri(props.uri, 'website_url')(state),
email: makeSelectMetadataItemForUri(props.uri, 'email')(state),
tags: makeSelectMetadataItemForUri(props.uri, 'tags')(state),
locations: makeSelectMetadataItemForUri(props.uri, 'locations')(state),
languages: makeSelectMetadataItemForUri(props.uri, 'languages')(state),
amount: makeSelectAmountForUri(props.uri)(state),
2020-06-21 18:51:06 +02:00
updateError: selectUpdateChannelError(state),
2020-06-22 17:19:55 +02:00
updatingChannel: selectUpdatingChannel(state),
2020-06-29 21:54:07 +02:00
createError: selectCreateChannelError(state),
creatingChannel: selectCreatingChannel(state),
balance: selectBalance(state),
isClaimingInitialRewards: selectIsClaimingInitialRewards(state),
hasClaimedInitialRewards: selectHasClaimedInitialRewards(state),
});
const perform = (dispatch) => ({
2020-06-29 21:54:07 +02:00
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
updateChannel: (params) => dispatch(doUpdateChannel(params)),
createChannel: (params) => {
2020-06-29 21:54:07 +02:00
const { name, amount, ...optionalParams } = params;
return dispatch(
doCreateChannel('@' + name, amount, optionalParams, (channelClaim) => {
dispatch(doUpdateBlockListForPublishedChannel(channelClaim));
})
);
2020-06-29 21:54:07 +02:00
},
clearChannelErrors: () => dispatch(doClearChannelErrors()),
claimInitialRewards: () => dispatch(doClaimInitialRewards()),
});
export default connect(select, perform)(ChannelForm);