fixes: default channel bid and publish form (#3781)

Changes channel default bid and fixes publish form errors around bid amount.
This commit is contained in:
Thomas Zarebczan 2020-03-02 12:11:14 -05:00 committed by GitHub
parent f23729dad6
commit 3ee25f8251
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 7 deletions

View file

@ -29,6 +29,7 @@ type Props = {
publish: (?string) => void, publish: (?string) => void,
filePath: ?string, filePath: ?string,
bid: ?number, bid: ?number,
bidError: ?string,
editingURI: ?string, editingURI: ?string,
title: ?string, title: ?string,
thumbnail: ?string, thumbnail: ?string,
@ -74,6 +75,7 @@ function PublishForm(props: Props) {
resolveUri, resolveUri,
title, title,
bid, bid,
bidError,
uploadThumbnailStatus, uploadThumbnailStatus,
resetThumbnailStatus, resetThumbnailStatus,
updatePublishForm, updatePublishForm,
@ -90,7 +92,12 @@ function PublishForm(props: Props) {
// If they are editing, they don't need a new file chosen // If they are editing, they don't need a new file chosen
const formValidLessFile = const formValidLessFile =
name && isNameValid(name, false) && title && bid && !(uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS); name &&
isNameValid(name, false) &&
title &&
bid &&
!bidError &&
!(uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS);
const formValid = editingURI && !filePath ? isStillEditing && formValidLessFile : formValidLessFile; const formValid = editingURI && !filePath ? isStillEditing && formValidLessFile : formValidLessFile;
let submitLabel; let submitLabel;

View file

@ -6,6 +6,7 @@ const select = state => ({
name: makeSelectPublishFormValue('name')(state), name: makeSelectPublishFormValue('name')(state),
title: makeSelectPublishFormValue('title')(state), title: makeSelectPublishFormValue('title')(state),
bid: makeSelectPublishFormValue('bid')(state), bid: makeSelectPublishFormValue('bid')(state),
bidError: makeSelectPublishFormValue('bidError')(state),
editingUri: makeSelectPublishFormValue('editingUri')(state), editingUri: makeSelectPublishFormValue('editingUri')(state),
uploadThumbnailStatus: makeSelectPublishFormValue('uploadThumbnailStatus')(state), uploadThumbnailStatus: makeSelectPublishFormValue('uploadThumbnailStatus')(state),
isStillEditing: selectIsStillEditing(state), isStillEditing: selectIsStillEditing(state),

View file

@ -7,6 +7,7 @@ type Props = {
title: ?string, title: ?string,
name: ?string, name: ?string,
bid: ?string, bid: ?string,
bidError: ?string,
editingURI: ?string, editingURI: ?string,
filePath: ?string, filePath: ?string,
isStillEditing: boolean, isStillEditing: boolean,
@ -14,7 +15,7 @@ type Props = {
}; };
function PublishFormErrors(props: Props) { function PublishFormErrors(props: Props) {
const { name, title, bid, editingURI, filePath, isStillEditing, uploadThumbnailStatus } = props; const { name, title, bid, bidError, editingURI, filePath, isStillEditing, uploadThumbnailStatus } = props;
// These are extra help // These are extra help
// If there is an error it will be presented as an inline error as well // If there is an error it will be presented as an inline error as well
@ -24,6 +25,7 @@ function PublishFormErrors(props: Props) {
{!name && <div>{__('A URL is required')}</div>} {!name && <div>{__('A URL is required')}</div>}
{!isNameValid(name, false) && INVALID_NAME_ERROR} {!isNameValid(name, false) && INVALID_NAME_ERROR}
{!bid && <div>{__('A deposit amount is required')}</div>} {!bid && <div>{__('A deposit amount is required')}</div>}
{bidError && <div>{__('Please check your deposit amount.')}</div>}
{uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS && ( {uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS && (
<div>{__('Please wait for thumbnail to finish uploading')}</div> <div>{__('Please wait for thumbnail to finish uploading')}</div>
)} )}

View file

@ -62,15 +62,16 @@ function PublishName(props: Props) {
let bidError; let bidError;
if (bid === 0) { if (bid === 0) {
bidError = __('Deposit cannot be 0'); bidError = __('Deposit cannot be 0');
} else if (totalAvailableBidAmount === bid) {
bidError = __('Please decrease your deposit to account for transaction fees');
} else if (totalAvailableBidAmount < bid) {
bidError = __('Deposit cannot be higher than your balance');
} else if (bid < MINIMUM_PUBLISH_BID) { } else if (bid < MINIMUM_PUBLISH_BID) {
bidError = __('Your deposit must be higher'); bidError = __('Your deposit must be higher');
} else if (totalAvailableBidAmount < bid) {
bidError = __('Deposit cannot be higher than your balance');
} else if (totalAvailableBidAmount <= bid + 0.05) {
bidError = __('Please decrease your deposit to account for transaction fees or acquire more LBC.');
} }
setBidError(bidError); setBidError(bidError);
updatePublishForm({ bidError: bidError });
}, [bid, previousBidAmount, balance]); }, [bid, previousBidAmount, balance]);
return ( return (

View file

@ -4,7 +4,7 @@ import { isNameValid } from 'lbry-redux';
import Button from 'component/button'; import Button from 'component/button';
import { Form, FormField } from 'component/common/form'; import { Form, FormField } from 'component/common/form';
import { INVALID_NAME_ERROR } from 'constants/claim'; import { INVALID_NAME_ERROR } from 'constants/claim';
export const DEFAULT_BID_FOR_FIRST_CHANNEL = 0.5; export const DEFAULT_BID_FOR_FIRST_CHANNEL = 0.01;
type Props = { type Props = {
createChannel: (string, number) => void, createChannel: (string, number) => void,