Add code review requests
This commit is contained in:
parent
42b456307f
commit
4022273408
6 changed files with 14 additions and 162 deletions
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
|
@ -11,9 +11,8 @@ import I18nMessage from 'component/i18nMessage';
|
||||||
import analytics from 'analytics';
|
import analytics from 'analytics';
|
||||||
import { sortLanguageMap } from 'util/default-languages';
|
import { sortLanguageMap } from 'util/default-languages';
|
||||||
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
||||||
import Spaceman from 'component/channelThumbnail/spaceman.png';
|
|
||||||
import ThumbnailBrokenImage from 'component/selectThumbnail/thumbnail-broken.png';
|
import ThumbnailBrokenImage from 'component/selectThumbnail/thumbnail-broken.png';
|
||||||
import { THUMBNAIL_CDN_SIZE_LIMIT_BYTES } from 'config';
|
import { AVATAR_DEFAULT, THUMBNAIL_CDN_SIZE_LIMIT_BYTES } from 'config';
|
||||||
import * as ICONS from 'constants/icons';
|
import * as ICONS from 'constants/icons';
|
||||||
|
|
||||||
export const DEFAULT_BID_FOR_FIRST_CHANNEL = 0.01;
|
export const DEFAULT_BID_FOR_FIRST_CHANNEL = 0.01;
|
||||||
|
@ -24,7 +23,6 @@ type Props = {
|
||||||
createChannelError: string,
|
createChannelError: string,
|
||||||
claimingReward: boolean,
|
claimingReward: boolean,
|
||||||
user: User,
|
user: User,
|
||||||
languages: Array<string>,
|
|
||||||
doToggleInterestedInYoutubeSync: () => void,
|
doToggleInterestedInYoutubeSync: () => void,
|
||||||
openModal: (
|
openModal: (
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -38,7 +36,6 @@ function UserFirstChannel(props: Props) {
|
||||||
creatingChannel,
|
creatingChannel,
|
||||||
claimingReward,
|
claimingReward,
|
||||||
user,
|
user,
|
||||||
languages = [],
|
|
||||||
createChannelError,
|
createChannelError,
|
||||||
doToggleInterestedInYoutubeSync,
|
doToggleInterestedInYoutubeSync,
|
||||||
openModal,
|
openModal,
|
||||||
|
@ -52,16 +49,10 @@ function UserFirstChannel(props: Props) {
|
||||||
const [params, setParams]: [any, (any) => void] = React.useState(getChannelParams());
|
const [params, setParams]: [any, (any) => void] = React.useState(getChannelParams());
|
||||||
|
|
||||||
const LANG_NONE = 'none';
|
const LANG_NONE = 'none';
|
||||||
const languageParam = params.languages;
|
const [languageParam, setLanguageParam] = useState([]);
|
||||||
const primaryLanguage = Array.isArray(languageParam) && languageParam.length && languageParam[0];
|
const primaryLanguage = Array.isArray(languageParam) && languageParam.length && languageParam[0];
|
||||||
const [nameError, setNameError] = useState(undefined);
|
const [nameError, setNameError] = useState(undefined);
|
||||||
|
|
||||||
var optionalParams = {
|
|
||||||
title: title,
|
|
||||||
thumbnailUrl: params.thumbnailUrl,
|
|
||||||
languages: primaryLanguage,
|
|
||||||
};
|
|
||||||
|
|
||||||
function getChannelParams() {
|
function getChannelParams() {
|
||||||
// fill this in with sdk data
|
// fill this in with sdk data
|
||||||
const channelParams: {
|
const channelParams: {
|
||||||
|
@ -69,14 +60,14 @@ function UserFirstChannel(props: Props) {
|
||||||
languages: ?Array<string>,
|
languages: ?Array<string>,
|
||||||
} = {
|
} = {
|
||||||
title,
|
title,
|
||||||
languages: languages || [],
|
languages: languageParam || [],
|
||||||
};
|
};
|
||||||
return channelParams;
|
return channelParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
let thumbnailPreview;
|
let thumbnailPreview;
|
||||||
if (!params.thumbnailUrl) {
|
if (!params.thumbnailUrl) {
|
||||||
thumbnailPreview = Spaceman;
|
thumbnailPreview = AVATAR_DEFAULT;
|
||||||
} else if (thumbError) {
|
} else if (thumbError) {
|
||||||
thumbnailPreview = ThumbnailBrokenImage;
|
thumbnailPreview = ThumbnailBrokenImage;
|
||||||
} else {
|
} else {
|
||||||
|
@ -105,11 +96,16 @@ function UserFirstChannel(props: Props) {
|
||||||
langs[index] = code;
|
langs[index] = code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setParams({ ...params, languages: langs });
|
setLanguageParam(langs);
|
||||||
|
// setParams({ ...params, languages: langs });
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCreateChannel() {
|
function handleCreateChannel() {
|
||||||
createChannel(`@${channel}`, DEFAULT_BID_FOR_FIRST_CHANNEL, optionalParams).then((channelClaim) => {
|
createChannel(`@${channel}`, DEFAULT_BID_FOR_FIRST_CHANNEL, {
|
||||||
|
title: title,
|
||||||
|
thumbnailUrl: params.thumbnailUrl,
|
||||||
|
languages: primaryLanguage,
|
||||||
|
}).then((channelClaim) => {
|
||||||
if (channelClaim) {
|
if (channelClaim) {
|
||||||
analytics.apiLogPublish(channelClaim);
|
analytics.apiLogPublish(channelClaim);
|
||||||
}
|
}
|
||||||
|
@ -144,7 +140,7 @@ function UserFirstChannel(props: Props) {
|
||||||
actions={
|
actions={
|
||||||
<Form onSubmit={handleCreateChannel}>
|
<Form onSubmit={handleCreateChannel}>
|
||||||
<fieldset-section>
|
<fieldset-section>
|
||||||
<label>Avatar</label>
|
<label>{__('Avatar')}</label>
|
||||||
<div className="form-field__avatar_upload">
|
<div className="form-field__avatar_upload">
|
||||||
<img className="form-field__avatar" src={thumbnailPreview} />
|
<img className="form-field__avatar" src={thumbnailPreview} />
|
||||||
<Button
|
<Button
|
||||||
|
@ -171,7 +167,7 @@ function UserFirstChannel(props: Props) {
|
||||||
autoFocus
|
autoFocus
|
||||||
type="text"
|
type="text"
|
||||||
name="channel_title2"
|
name="channel_title2"
|
||||||
label={__('Title')}
|
label={__('Display Name')}
|
||||||
placeholder={__('My Awesome Channel')}
|
placeholder={__('My Awesome Channel')}
|
||||||
value={title}
|
value={title}
|
||||||
onChange={handleTitleChange}
|
onChange={handleTitleChange}
|
||||||
|
@ -183,7 +179,7 @@ function UserFirstChannel(props: Props) {
|
||||||
{createChannelError || nameError ? (
|
{createChannelError || nameError ? (
|
||||||
<span className="error__text">{createChannelError || nameError}</span>
|
<span className="error__text">{createChannelError || nameError}</span>
|
||||||
) : (
|
) : (
|
||||||
__('Your Channel')
|
__('Username')
|
||||||
)}
|
)}
|
||||||
</label>
|
</label>
|
||||||
<div className="form-field__prefix">@</div>
|
<div className="form-field__prefix">@</div>
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import { selectUser, selectEmailToVerify } from 'redux/selectors/user';
|
|
||||||
import { selectCreatingChannel, selectMyChannelClaims, selectCreateChannelError } from 'redux/selectors/claims';
|
|
||||||
import { doCreateChannel } from 'redux/actions/claims';
|
|
||||||
import UserFirstChannelDetails from './view';
|
|
||||||
|
|
||||||
const select = (state) => ({
|
|
||||||
email: selectEmailToVerify(state),
|
|
||||||
user: selectUser(state),
|
|
||||||
channels: selectMyChannelClaims(state),
|
|
||||||
creatingChannel: selectCreatingChannel(state),
|
|
||||||
createChannelError: selectCreateChannelError(state),
|
|
||||||
});
|
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
|
||||||
createChannel: (name, amount) => dispatch(doCreateChannel(name, amount)),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(select, perform)(UserFirstChannelDetails);
|
|
|
@ -1,118 +0,0 @@
|
||||||
// @flow
|
|
||||||
import React, { useState } from 'react';
|
|
||||||
import { isNameValid } from 'util/lbryURI';
|
|
||||||
import Button from 'component/button';
|
|
||||||
import { Form, FormField } from 'component/common/form';
|
|
||||||
import { INVALID_NAME_ERROR } from 'constants/claim';
|
|
||||||
import Card from 'component/common/card';
|
|
||||||
import I18nMessage from 'component/i18nMessage';
|
|
||||||
import analytics from 'analytics';
|
|
||||||
|
|
||||||
export const DEFAULT_BID_FOR_FIRST_CHANNEL = 0.01;
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
createChannel: (string, number) => Promise<ChannelClaim>,
|
|
||||||
creatingChannel: boolean,
|
|
||||||
createChannelError: string,
|
|
||||||
claimingReward: boolean,
|
|
||||||
user: User,
|
|
||||||
doToggleInterestedInYoutubeSync: () => void,
|
|
||||||
};
|
|
||||||
|
|
||||||
function UserFirstChannelDetails(props: Props) {
|
|
||||||
const {
|
|
||||||
createChannel,
|
|
||||||
creatingChannel,
|
|
||||||
claimingReward,
|
|
||||||
user,
|
|
||||||
createChannelError,
|
|
||||||
doToggleInterestedInYoutubeSync,
|
|
||||||
} = props;
|
|
||||||
const { primary_email: primaryEmail } = user;
|
|
||||||
const initialChannel = primaryEmail ? primaryEmail.split('@')[0] : '';
|
|
||||||
const [channel, setChannel] = useState(initialChannel);
|
|
||||||
const [nameError, setNameError] = useState(undefined);
|
|
||||||
|
|
||||||
function handleCreateChannel() {
|
|
||||||
createChannel(`@${channel}`, DEFAULT_BID_FOR_FIRST_CHANNEL).then((channelClaim) => {
|
|
||||||
if (channelClaim) {
|
|
||||||
analytics.apiLogPublish(channelClaim);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleChannelChange(e) {
|
|
||||||
const { value } = e.target;
|
|
||||||
setChannel(value);
|
|
||||||
if (!isNameValid(value)) {
|
|
||||||
setNameError(INVALID_NAME_ERROR);
|
|
||||||
} else {
|
|
||||||
setNameError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="main__channel-creation">
|
|
||||||
<Card
|
|
||||||
title={__('Create a Channel')}
|
|
||||||
subtitle={
|
|
||||||
<React.Fragment>
|
|
||||||
<p>{__('Your channel will be used for publishing and commenting.')}</p>
|
|
||||||
<p>{__('You can have more than one or remove it later.')}</p>
|
|
||||||
</React.Fragment>
|
|
||||||
}
|
|
||||||
actions={
|
|
||||||
<Form onSubmit={handleCreateChannel}>
|
|
||||||
<fieldset-group class="fieldset-group--smushed fieldset-group--disabled-prefix">
|
|
||||||
<fieldset-section>
|
|
||||||
<label htmlFor="auth_first_channel">
|
|
||||||
{createChannelError || nameError ? (
|
|
||||||
<span className="error__text">{createChannelError || nameError}</span>
|
|
||||||
) : (
|
|
||||||
__('Your Channel')
|
|
||||||
)}
|
|
||||||
</label>
|
|
||||||
<div className="form-field__prefix">@</div>
|
|
||||||
</fieldset-section>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
autoFocus
|
|
||||||
placeholder={__('channel')}
|
|
||||||
type="text"
|
|
||||||
name="auth_first_channel"
|
|
||||||
className="form-field--short"
|
|
||||||
value={channel}
|
|
||||||
onChange={handleChannelChange}
|
|
||||||
/>
|
|
||||||
</fieldset-group>
|
|
||||||
<div className="section__actions">
|
|
||||||
<Button
|
|
||||||
button="primary"
|
|
||||||
type="submit"
|
|
||||||
disabled={nameError || !channel || creatingChannel || claimingReward}
|
|
||||||
label={creatingChannel || claimingReward ? __('Creating') : __('Create')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="help--card-actions">
|
|
||||||
<I18nMessage
|
|
||||||
tokens={{
|
|
||||||
sync_channel: (
|
|
||||||
<Button
|
|
||||||
button="link"
|
|
||||||
label={__('Sync it and skip this step')}
|
|
||||||
onClick={() => doToggleInterestedInYoutubeSync()}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Have a YouTube channel? %sync_channel%.
|
|
||||||
</I18nMessage>
|
|
||||||
</div>
|
|
||||||
</Form>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default UserFirstChannelDetails;
|
|
|
@ -172,11 +172,6 @@ function UserSignUp(props: Props) {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
/*
|
|
||||||
showChannelDetailsUpdate && (
|
|
||||||
<UserFirstChannelDetails />
|
|
||||||
),
|
|
||||||
*/
|
|
||||||
showChannelCreation &&
|
showChannelCreation &&
|
||||||
(interestedInYoutubeSync ? (
|
(interestedInYoutubeSync ? (
|
||||||
<YoutubeSync inSignUpFlow doToggleInterestedInYoutubeSync={doToggleInterestedInYoutubeSync} />
|
<YoutubeSync inSignUpFlow doToggleInterestedInYoutubeSync={doToggleInterestedInYoutubeSync} />
|
||||||
|
|
|
@ -431,8 +431,6 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
|
||||||
const state = getState();
|
const state = getState();
|
||||||
const channelCountOverLimit = selectIsMyChannelCountOverLimit(state);
|
const channelCountOverLimit = selectIsMyChannelCountOverLimit(state);
|
||||||
|
|
||||||
console.log('optionalParams: ', optionalParams);
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.CREATE_CHANNEL_STARTED,
|
type: ACTIONS.CREATE_CHANNEL_STARTED,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue