2020-01-30 22:01:23 +01:00
|
|
|
// @flow
|
|
|
|
import React from 'react';
|
|
|
|
import UriIndicator from 'component/uriIndicator';
|
|
|
|
import DateTime from 'component/dateTime';
|
|
|
|
import Button from 'component/button';
|
|
|
|
import { parseURI } from 'lbry-redux';
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
|
|
|
claim: ?Claim,
|
|
|
|
pending?: boolean,
|
|
|
|
type: string,
|
2021-02-16 22:09:20 +01:00
|
|
|
beginPublish: (string) => void,
|
2020-01-30 22:01:23 +01:00
|
|
|
};
|
|
|
|
|
2020-01-30 23:25:15 +01:00
|
|
|
function ClaimPreviewSubtitle(props: Props) {
|
2020-01-30 22:01:23 +01:00
|
|
|
const { pending, uri, claim, type, beginPublish } = props;
|
|
|
|
const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0;
|
|
|
|
|
|
|
|
let isChannel;
|
|
|
|
let name;
|
|
|
|
try {
|
|
|
|
({ streamName: name, isChannel } = parseURI(uri));
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="media__subtitle">
|
|
|
|
{claim ? (
|
|
|
|
<React.Fragment>
|
|
|
|
<UriIndicator uri={uri} link />{' '}
|
2020-05-07 14:22:55 +02:00
|
|
|
{!pending &&
|
|
|
|
claim &&
|
2020-08-26 22:28:33 +02:00
|
|
|
(isChannel ? (
|
|
|
|
type !== 'inline' && `${claimsInChannel} ${claimsInChannel === 1 ? __('upload') : __('uploads')}`
|
|
|
|
) : (
|
|
|
|
<DateTime timeAgo uri={uri} />
|
|
|
|
))}
|
2020-01-30 22:01:23 +01:00
|
|
|
</React.Fragment>
|
|
|
|
) : (
|
|
|
|
<React.Fragment>
|
2020-07-23 19:02:07 +02:00
|
|
|
<div>{__('Upload something and claim this spot!')}</div>
|
2020-01-30 22:01:23 +01:00
|
|
|
<div className="card__actions">
|
|
|
|
<Button onClick={() => beginPublish(name)} button="primary" label={__('Publish to %uri%', { uri })} />
|
|
|
|
</div>
|
|
|
|
</React.Fragment>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-01-30 23:25:15 +01:00
|
|
|
export default ClaimPreviewSubtitle;
|