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 { sortLanguageMap } from 'util/default-languages';
|
||||
import SUPPORTED_LANGUAGES from 'constants/supported_languages';
|
||||
import Spaceman from 'component/channelThumbnail/spaceman.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';
|
||||
|
||||
export const DEFAULT_BID_FOR_FIRST_CHANNEL = 0.01;
|
||||
|
@ -24,7 +23,6 @@ type Props = {
|
|||
createChannelError: string,
|
||||
claimingReward: boolean,
|
||||
user: User,
|
||||
languages: Array<string>,
|
||||
doToggleInterestedInYoutubeSync: () => void,
|
||||
openModal: (
|
||||
id: string,
|
||||
|
@ -38,7 +36,6 @@ function UserFirstChannel(props: Props) {
|
|||
creatingChannel,
|
||||
claimingReward,
|
||||
user,
|
||||
languages = [],
|
||||
createChannelError,
|
||||
doToggleInterestedInYoutubeSync,
|
||||
openModal,
|
||||
|
@ -52,16 +49,10 @@ function UserFirstChannel(props: Props) {
|
|||
const [params, setParams]: [any, (any) => void] = React.useState(getChannelParams());
|
||||
|
||||
const LANG_NONE = 'none';
|
||||
const languageParam = params.languages;
|
||||
const [languageParam, setLanguageParam] = useState([]);
|
||||
const primaryLanguage = Array.isArray(languageParam) && languageParam.length && languageParam[0];
|
||||
const [nameError, setNameError] = useState(undefined);
|
||||
|
||||
var optionalParams = {
|
||||
title: title,
|
||||
thumbnailUrl: params.thumbnailUrl,
|
||||
languages: primaryLanguage,
|
||||
};
|
||||
|
||||
function getChannelParams() {
|
||||
// fill this in with sdk data
|
||||
const channelParams: {
|
||||
|
@ -69,14 +60,14 @@ function UserFirstChannel(props: Props) {
|
|||
languages: ?Array<string>,
|
||||
} = {
|
||||
title,
|
||||
languages: languages || [],
|
||||
languages: languageParam || [],
|
||||
};
|
||||
return channelParams;
|
||||
}
|
||||
|
||||
let thumbnailPreview;
|
||||
if (!params.thumbnailUrl) {
|
||||
thumbnailPreview = Spaceman;
|
||||
thumbnailPreview = AVATAR_DEFAULT;
|
||||
} else if (thumbError) {
|
||||
thumbnailPreview = ThumbnailBrokenImage;
|
||||
} else {
|
||||
|
@ -105,11 +96,16 @@ function UserFirstChannel(props: Props) {
|
|||
langs[index] = code;
|
||||
}
|
||||
}
|
||||
setParams({ ...params, languages: langs });
|
||||
setLanguageParam(langs);
|
||||
// setParams({ ...params, languages: langs });
|
||||
}
|
||||
|
||||
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) {
|
||||
analytics.apiLogPublish(channelClaim);
|
||||
}
|
||||
|
@ -144,7 +140,7 @@ function UserFirstChannel(props: Props) {
|
|||
actions={
|
||||
<Form onSubmit={handleCreateChannel}>
|
||||
<fieldset-section>
|
||||
<label>Avatar</label>
|
||||
<label>{__('Avatar')}</label>
|
||||
<div className="form-field__avatar_upload">
|
||||
<img className="form-field__avatar" src={thumbnailPreview} />
|
||||
<Button
|
||||
|
@ -171,7 +167,7 @@ function UserFirstChannel(props: Props) {
|
|||
autoFocus
|
||||
type="text"
|
||||
name="channel_title2"
|
||||
label={__('Title')}
|
||||
label={__('Display Name')}
|
||||
placeholder={__('My Awesome Channel')}
|
||||
value={title}
|
||||
onChange={handleTitleChange}
|
||||
|
@ -183,7 +179,7 @@ function UserFirstChannel(props: Props) {
|
|||
{createChannelError || nameError ? (
|
||||
<span className="error__text">{createChannelError || nameError}</span>
|
||||
) : (
|
||||
__('Your Channel')
|
||||
__('Username')
|
||||
)}
|
||||
</label>
|
||||
<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 &&
|
||||
(interestedInYoutubeSync ? (
|
||||
<YoutubeSync inSignUpFlow doToggleInterestedInYoutubeSync={doToggleInterestedInYoutubeSync} />
|
||||
|
|
|
@ -431,8 +431,6 @@ export function doCreateChannel(name: string, amount: number, optionalParams: an
|
|||
const state = getState();
|
||||
const channelCountOverLimit = selectIsMyChannelCountOverLimit(state);
|
||||
|
||||
console.log('optionalParams: ', optionalParams);
|
||||
|
||||
dispatch({
|
||||
type: ACTIONS.CREATE_CHANNEL_STARTED,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue