From 91f28d7be1f860e9868e90977d216516551605cc Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 24 Jul 2019 14:21:34 -0400 Subject: [PATCH] hotfix for invalid names --- src/ui/component/publishForm/view.jsx | 5 +++-- src/ui/component/publishFormErrors/view.jsx | 3 ++- src/ui/component/selectChannel/view.jsx | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ui/component/publishForm/view.jsx b/src/ui/component/publishForm/view.jsx index 8d09a44c2..bae773b6f 100644 --- a/src/ui/component/publishForm/view.jsx +++ b/src/ui/component/publishForm/view.jsx @@ -1,7 +1,7 @@ // @flow import React, { useEffect, Fragment } from 'react'; import { CHANNEL_NEW, CHANNEL_ANONYMOUS } from 'constants/claim'; -import { buildURI, isURIValid, THUMBNAIL_STATUSES } from 'lbry-redux'; +import { buildURI, isURIValid, isNameValid, THUMBNAIL_STATUSES } from 'lbry-redux'; import Button from 'component/button'; import ChannelSection from 'component/selectChannel'; import classnames from 'classnames'; @@ -77,7 +77,8 @@ function PublishForm(props: Props) { } = props; const formDisabled = (!filePath && !editingURI) || publishing; // If they are editing, they don't need a new file chosen - const formValidLessFile = name && title && bid && !(uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS); + const formValidLessFile = + name && isNameValid(name, false) && title && bid && !(uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS); const formValid = editingURI && !filePath ? isStillEditing && formValidLessFile : formValidLessFile; let submitLabel; diff --git a/src/ui/component/publishFormErrors/view.jsx b/src/ui/component/publishFormErrors/view.jsx index 28a0b862f..914236a54 100644 --- a/src/ui/component/publishFormErrors/view.jsx +++ b/src/ui/component/publishFormErrors/view.jsx @@ -1,6 +1,6 @@ // @flow import React from 'react'; -import { THUMBNAIL_STATUSES } from 'lbry-redux'; +import { THUMBNAIL_STATUSES, isNameValid } from 'lbry-redux'; type Props = { title: ?string, @@ -21,6 +21,7 @@ function PublishFormErrors(props: Props) {
{!title &&
{__('A title is required')}
} {!name &&
{__('A URL is required')}
} + {!isNameValid(name, false) && __('LBRY names cannot contain spaces or reserved symbols ($#@;/"<>%{}|^~[]`)')} {!bid &&
{__('A deposit amount is required')}
} {uploadThumbnailStatus === THUMBNAIL_STATUSES.IN_PROGRESS && (
{__('Please wait for thumbnail to finish uploading')}
diff --git a/src/ui/component/selectChannel/view.jsx b/src/ui/component/selectChannel/view.jsx index 0194154ff..5d9eb6ae8 100644 --- a/src/ui/component/selectChannel/view.jsx +++ b/src/ui/component/selectChannel/view.jsx @@ -76,8 +76,8 @@ class ChannelSection extends React.PureComponent { } let newChannelNameError; - if (newChannelName.length > 1 && !isNameValid(newChannelName.substr(1), false)) { - newChannelNameError = __('LBRY channel names must contain only letters, numbers and dashes.'); + if (newChannelName.length > 0 && !isNameValid(newChannelName, false)) { + newChannelNameError = __('LBRY names cannot contain spaces or reserved symbols ($#@;/"<>%{}|^~[]`)'); } this.setState({ @@ -107,7 +107,7 @@ class ChannelSection extends React.PureComponent { const { balance, createChannel, onChannelChange } = this.props; const { newChannelBid, newChannelName } = this.state; - const channelName = `@${newChannelName}`; + const channelName = `@${newChannelName.trim()}`; if (newChannelBid > balance) { return;