improve flow when a user has no channels/no publishes on a channel
This commit is contained in:
parent
cf4bbc3f26
commit
594bcea01f
3 changed files with 13 additions and 41 deletions
|
@ -1,16 +1,15 @@
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import ChannelCreate from './view';
|
import ChannelCreate from './view';
|
||||||
import { selectBalance, doCreateChannel } from 'lbry-redux';
|
import { selectBalance, doCreateChannel, selectCreatingChannel, selectCreateChannelError } from 'lbry-redux';
|
||||||
|
|
||||||
const select = state => ({
|
const select = state => ({
|
||||||
balance: selectBalance(state),
|
balance: selectBalance(state),
|
||||||
|
creatingChannel: selectCreatingChannel(state),
|
||||||
|
createChannelError: selectCreateChannelError(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
const perform = dispatch => ({
|
const perform = dispatch => ({
|
||||||
createChannel: (name, amount) => dispatch(doCreateChannel(name, amount)),
|
createChannel: (name, amount) => dispatch(doCreateChannel(name, amount)),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(
|
export default connect(select, perform)(ChannelCreate);
|
||||||
select,
|
|
||||||
perform
|
|
||||||
)(ChannelCreate);
|
|
||||||
|
|
|
@ -11,15 +11,15 @@ type Props = {
|
||||||
balance: number,
|
balance: number,
|
||||||
createChannel: (string, number) => Promise<any>,
|
createChannel: (string, number) => Promise<any>,
|
||||||
onSuccess?: ({}) => void,
|
onSuccess?: ({}) => void,
|
||||||
|
creatingChannel: boolean,
|
||||||
|
createChannelError: ?string,
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
newChannelName: string,
|
newChannelName: string,
|
||||||
newChannelBid: number,
|
newChannelBid: number,
|
||||||
creatingChannel: boolean,
|
|
||||||
newChannelNameError: string,
|
newChannelNameError: string,
|
||||||
newChannelBidError: string,
|
newChannelBidError: string,
|
||||||
createChannelError: ?string,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChannelCreate extends React.PureComponent<Props, State> {
|
class ChannelCreate extends React.PureComponent<Props, State> {
|
||||||
|
@ -29,10 +29,8 @@ class ChannelCreate extends React.PureComponent<Props, State> {
|
||||||
this.state = {
|
this.state = {
|
||||||
newChannelName: '',
|
newChannelName: '',
|
||||||
newChannelBid: 0.01,
|
newChannelBid: 0.01,
|
||||||
creatingChannel: false,
|
|
||||||
newChannelNameError: '',
|
newChannelNameError: '',
|
||||||
newChannelBidError: '',
|
newChannelBidError: '',
|
||||||
createChannelError: undefined,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
(this: any).handleNewChannelNameChange = this.handleNewChannelNameChange.bind(this);
|
(this: any).handleNewChannelNameChange = this.handleNewChannelNameChange.bind(this);
|
||||||
|
@ -78,24 +76,12 @@ class ChannelCreate extends React.PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleCreateChannel() {
|
handleCreateChannel() {
|
||||||
const { balance, createChannel, onSuccess } = this.props;
|
const { createChannel, onSuccess } = this.props;
|
||||||
const { newChannelBid, newChannelName } = this.state;
|
const { newChannelBid, newChannelName } = this.state;
|
||||||
|
|
||||||
const channelName = `@${newChannelName.trim()}`;
|
const channelName = `@${newChannelName.trim()}`;
|
||||||
|
|
||||||
if (newChannelBid > balance) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
|
||||||
creatingChannel: true,
|
|
||||||
createChannelError: undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
const success = channelClaim => {
|
const success = channelClaim => {
|
||||||
this.setState({
|
|
||||||
creatingChannel: false,
|
|
||||||
});
|
|
||||||
analytics.apiLogPublish(channelClaim);
|
analytics.apiLogPublish(channelClaim);
|
||||||
|
|
||||||
if (onSuccess !== undefined) {
|
if (onSuccess !== undefined) {
|
||||||
|
@ -103,25 +89,12 @@ class ChannelCreate extends React.PureComponent<Props, State> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const failure = () => {
|
createChannel(channelName, newChannelBid).then(success);
|
||||||
this.setState({
|
|
||||||
creatingChannel: false,
|
|
||||||
createChannelError: __('Unable to create channel due to an internal error.'),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
createChannel(channelName, newChannelBid).then(success, failure);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { newChannelName, newChannelNameError, newChannelBid, newChannelBidError } = this.state;
|
||||||
newChannelName,
|
const { creatingChannel, createChannelError } = this.props;
|
||||||
newChannelNameError,
|
|
||||||
newChannelBid,
|
|
||||||
newChannelBidError,
|
|
||||||
creatingChannel,
|
|
||||||
createChannelError,
|
|
||||||
} = this.state;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form onSubmit={this.handleCreateChannel}>
|
<Form onSubmit={this.handleCreateChannel}>
|
||||||
|
|
|
@ -36,7 +36,7 @@ export default function CreatorAnalytics(props: Props) {
|
||||||
|
|
||||||
const channelForEffect = JSON.stringify(claim);
|
const channelForEffect = JSON.stringify(claim);
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (claimId && channelForEffect) {
|
if (claimId && channelForEffect && channelHasClaims) {
|
||||||
setFetchingStats(true);
|
setFetchingStats(true);
|
||||||
Lbryio.call('reports', 'content', { claim_id: claimId })
|
Lbryio.call('reports', 'content', { claim_id: claimId })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
|
@ -55,7 +55,7 @@ export default function CreatorAnalytics(props: Props) {
|
||||||
setFetchingStats(false);
|
setFetchingStats(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [claimId, channelForEffect, setFetchingStats, setStats]);
|
}, [claimId, channelForEffect, channelHasClaims, setFetchingStats, setStats]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
@ -174,7 +174,7 @@ export default function CreatorAnalytics(props: Props) {
|
||||||
body={
|
body={
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<div className="card--inline">
|
<div className="card--inline">
|
||||||
<ClaimPreview uri={stats.VideoViewsTopNew} />
|
<ClaimPreview uri={stats.VideoURITopNew} />
|
||||||
</div>
|
</div>
|
||||||
<div className="section__subtitle card__data-subtitle">
|
<div className="section__subtitle card__data-subtitle">
|
||||||
<span>
|
<span>
|
||||||
|
|
Loading…
Reference in a new issue