// @flow import * as React from 'react'; import Button from 'component/button'; import { buildURI } from 'util/lbryURI'; import I18nMessage from 'component/i18nMessage'; function isUriPendingUpload(uri: ?string, currentUploadNames: Array) { const protocol = 'lbry://'; const uriName = uri && uri.startsWith(protocol) ? uri.substring(protocol.length) : uri; return currentUploadNames.includes(uriName); } type Props = { uri: ?string, myClaimForUri: ?StreamClaim, myClaimForUriCaseInsensitive: ?StreamClaim, currentUploads: { [key: string]: FileUploadItem }, isStillEditing: boolean, onEditMyClaim: (any, string) => void, }; function NameHelpText(props: Props) { const { uri, myClaimForUri, myClaimForUriCaseInsensitive, currentUploads, onEditMyClaim, isStillEditing } = props; const currentUploadNames: Array = React.useMemo(() => { // $FlowFixMe - unable to resolve mixed return Object.values(currentUploads).map((x) => (x.params ? x.params.name : '')); }, [currentUploads]); let nameHelpText; if (isStillEditing) { nameHelpText = __('You are currently editing this claim.'); } else if (isUriPendingUpload(uri, currentUploadNames)) { nameHelpText = (
{/* prettier-ignore */} {uri}) }}> You already have a pending upload at %existing_uri%.
); } else if (uri && myClaimForUri) { const editUri = buildURI({ streamName: myClaimForUri.name, streamClaimId: myClaimForUri.claim_id, }); nameHelpText = (
{uri} ), }} > You already have a claim at %existing_uri%. Publishing will update (overwrite) your existing claim.