diff --git a/ui/component/claimPreview/view.jsx b/ui/component/claimPreview/view.jsx index 89edc23d6..68349c139 100644 --- a/ui/component/claimPreview/view.jsx +++ b/ui/component/claimPreview/view.jsx @@ -5,7 +5,7 @@ import { NavLink, withRouter } from 'react-router-dom'; import { isEmpty } from 'util/object'; import { lazyImport } from 'util/lazyImport'; import classnames from 'classnames'; -import { parseURI, isURIEqual } from 'util/lbryURI'; +import { isURIEqual, isURIValid } from 'util/lbryURI'; import * as COLLECTIONS_CONSTS from 'constants/collections'; import { formatLbryUrlForWeb } from 'util/url'; import { formatClaimPreviewTitle } from 'util/formatAriaLabel'; @@ -180,15 +180,8 @@ const ClaimPreview = forwardRef((props: Props, ref: any) => { ); }, [channelSubCount]); - let isValid = false; - if (uri) { - try { - parseURI(uri); - isValid = true; - } catch (e) { - isValid = false; - } - } + const isValid = uri && isURIValid(uri); + // $FlowFixMe const isPlayable = claim && diff --git a/ui/component/claimTilesDiscover/view.jsx b/ui/component/claimTilesDiscover/view.jsx index 351f8cf07..359800565 100644 --- a/ui/component/claimTilesDiscover/view.jsx +++ b/ui/component/claimTilesDiscover/view.jsx @@ -8,6 +8,7 @@ import usePrevious from 'effects/use-previous'; type SearchOptions = { page_size: number, + page: number, no_totals: boolean, any_tags: Array, channel_ids: Array, diff --git a/ui/component/collectionEdit/view.jsx b/ui/component/collectionEdit/view.jsx index c835caed2..9a0fa3b98 100644 --- a/ui/component/collectionEdit/view.jsx +++ b/ui/component/collectionEdit/view.jsx @@ -249,7 +249,7 @@ function CollectionForm(props: Props) { let nameError; if (!name && name !== undefined) { nameError = __('A name is required for your url'); - } else if (!isNameValid(name, false)) { + } else if (!isNameValid(name)) { nameError = INVALID_NAME_ERROR; } diff --git a/ui/component/commentMenuList/view.jsx b/ui/component/commentMenuList/view.jsx index da1b7b3b7..66170f6ef 100644 --- a/ui/component/commentMenuList/view.jsx +++ b/ui/component/commentMenuList/view.jsx @@ -94,7 +94,7 @@ function CommentMenuList(props: Props) { function assignAsModerator() { if (activeChannelClaim && authorUri) { const { channelName, channelClaimId } = parseURI(authorUri); - commentModAddDelegate(channelClaimId, channelName, activeChannelClaim); + if (channelName && channelClaimId) commentModAddDelegate(channelClaimId, channelName, activeChannelClaim); } } diff --git a/ui/component/notificationContentChannelMenu/view.jsx b/ui/component/notificationContentChannelMenu/view.jsx index de4484571..963b87aa7 100644 --- a/ui/component/notificationContentChannelMenu/view.jsx +++ b/ui/component/notificationContentChannelMenu/view.jsx @@ -14,8 +14,9 @@ type Props = { export default function NotificationContentChannelMenu(props: Props) { const { uri, notificationsDisabled, doToast, doChannelSubscribe } = props; - const { claimName } = parseURI(uri); - + let claimName; + const { claimName: name } = parseURI(uri); + claimName = name || ''; function handleClick() { doChannelSubscribe({ uri, diff --git a/ui/component/publishFormErrors/view.jsx b/ui/component/publishFormErrors/view.jsx index bcefce7d2..7f4de6312 100644 --- a/ui/component/publishFormErrors/view.jsx +++ b/ui/component/publishFormErrors/view.jsx @@ -43,7 +43,7 @@ function PublishFormErrors(props: Props) { {waitForFile &&
{__('Choose a replay file, or select None')}
} {!title &&
{__('A title is required')}
} {!name &&
{__('A URL is required')}
} - {!isNameValid(name, false) && INVALID_NAME_ERROR} + {name && !isNameValid(name) && INVALID_NAME_ERROR} {!bid &&
{__('A deposit amount is required')}
} {bidError &&
{__('Please check your deposit amount.')}
} {isUploadingThumbnail &&
{__('Please wait for thumbnail to finish uploading')}
} diff --git a/ui/component/repostCreate/view.jsx b/ui/component/repostCreate/view.jsx index 935418a12..e8ccc9fb1 100644 --- a/ui/component/repostCreate/view.jsx +++ b/ui/component/repostCreate/view.jsx @@ -165,7 +165,7 @@ function RepostCreate(props: Props) { let repostNameError; if (!enteredRepostName) { repostNameError = __('A name is required'); - } else if (!isNameValid(enteredRepostName, false)) { + } else if (!isNameValid(enteredRepostName)) { repostNameError = INVALID_NAME_ERROR; } else if (!available) { repostNameError = __('You already have a claim with this name.'); @@ -178,7 +178,7 @@ function RepostCreate(props: Props) { } React.useEffect(() => { - if (enteredRepostName && isNameValid(enteredRepostName, false)) { + if (enteredRepostName && isNameValid(enteredRepostName)) { doCheckPublishNameAvailability(enteredRepostName).then((r) => setAvailable(r)); } }, [enteredRepostName, doCheckPublishNameAvailability]); @@ -262,14 +262,14 @@ function RepostCreate(props: Props) { } else if (entered) { try { const { claimName } = parseURI(entered); - return `/${claimName}`; + return claimName ? `/${claimName}` : '/'; } catch (e) { return '/'; } } else if (passed) { try { const { claimName } = parseURI(passed); - return `/${claimName}`; + return claimName ? `/${claimName}` : '/'; } catch (e) { return '/'; } diff --git a/ui/redux/actions/claims.js b/ui/redux/actions/claims.js index d97309e33..76f390fcd 100644 --- a/ui/redux/actions/claims.js +++ b/ui/redux/actions/claims.js @@ -605,7 +605,7 @@ export function doFetchCollectionListMine(page: number = 1, pageSize: number = 9 export function doClaimSearch( options: { - page_size: number, + page_size?: number, page: number, no_totals?: boolean, any_tags?: Array, diff --git a/ui/redux/selectors/claims.js b/ui/redux/selectors/claims.js index 4e0f02960..725a5c0cc 100644 --- a/ui/redux/selectors/claims.js +++ b/ui/redux/selectors/claims.js @@ -1,5 +1,5 @@ // @flow -import { normalizeURI, parseURI } from 'util/lbryURI'; +import { normalizeURI, parseURI, isURIValid } from 'util/lbryURI'; import { selectSupportsByOutpoint } from 'redux/selectors/wallet'; import { createSelector } from 'reselect'; import { isClaimNsfw, filterClaims } from 'util/claim'; @@ -76,11 +76,7 @@ export const makeSelectClaimForClaimId = (claimId: string) => createSelector(sel export const makeSelectClaimForUri = (uri: string, returnRepost: boolean = true) => createSelector(selectClaimIdsByUri, selectClaimsById, (byUri, byId) => { - let validUri; - try { - parseURI(uri); - validUri = true; - } catch (e) {} + const validUri = isURIValid(uri); if (validUri && byUri) { const claimId = uri && byUri[normalizeURI(uri)]; @@ -154,9 +150,7 @@ export const makeSelectClaimIsMine = (rawUri: string) => { } catch (e) {} return createSelector(selectClaimsByUri, selectMyActiveClaims, (claims, myClaims) => { - try { - parseURI(uri); - } catch (e) { + if (!isURIValid(uri)) { return false; }