2020-01-30 22:01:23 +01:00
|
|
|
// @flow
|
2021-03-17 21:53:35 +01:00
|
|
|
import { ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
2020-01-30 22:01:23 +01:00
|
|
|
import React from 'react';
|
|
|
|
import UriIndicator from 'component/uriIndicator';
|
|
|
|
import DateTime from 'component/dateTime';
|
|
|
|
import Button from 'component/button';
|
2021-09-09 09:02:31 +02:00
|
|
|
import FileViewCountInline from 'component/fileViewCountInline';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { parseURI } from 'util/lbryURI';
|
2020-01-30 22:01:23 +01:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
uri: string,
|
|
|
|
claim: ?Claim,
|
|
|
|
pending?: boolean,
|
|
|
|
type: string,
|
2021-10-17 10:36:14 +02:00
|
|
|
beginPublish: (?string) => void,
|
2021-03-17 21:53:35 +01:00
|
|
|
isLivestream: boolean,
|
2021-10-16 20:12:09 +02:00
|
|
|
fetchSubCount: (string) => void,
|
|
|
|
subCount: number,
|
2020-01-30 22:01:23 +01:00
|
|
|
};
|
|
|
|
|
2021-09-29 21:04:43 +02:00
|
|
|
// previews used in channel overview and homepage (and other places?)
|
2020-01-30 23:25:15 +01:00
|
|
|
function ClaimPreviewSubtitle(props: Props) {
|
2021-10-16 20:12:09 +02:00
|
|
|
const { pending, uri, claim, type, beginPublish, isLivestream, fetchSubCount, subCount } = props;
|
2020-01-30 22:01:23 +01:00
|
|
|
const claimsInChannel = (claim && claim.meta.claims_in_channel) || 0;
|
|
|
|
|
2021-10-16 20:12:09 +02:00
|
|
|
const claimId = (claim && claim.claim_id) || '0';
|
|
|
|
const formattedSubCount = Number(subCount).toLocaleString();
|
|
|
|
React.useEffect(() => {
|
|
|
|
fetchSubCount(claimId);
|
|
|
|
}, [uri, fetchSubCount, claimId]);
|
|
|
|
|
2020-01-30 22:01:23 +01:00
|
|
|
let isChannel;
|
|
|
|
let name;
|
|
|
|
try {
|
|
|
|
({ streamName: name, isChannel } = parseURI(uri));
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="media__subtitle">
|
|
|
|
{claim ? (
|
|
|
|
<React.Fragment>
|
|
|
|
<UriIndicator uri={uri} link />{' '}
|
2021-03-17 21:53:35 +01:00
|
|
|
{!pending && claim && (
|
|
|
|
<>
|
2021-10-16 20:12:09 +02:00
|
|
|
{isChannel && type !== 'inline' && (
|
|
|
|
<>
|
|
|
|
<span className="claim-preview-metadata-sub-upload">
|
|
|
|
{formattedSubCount} {subCount !== 1 ? __('Followers') : __('Follower')}
|
|
|
|
• {claimsInChannel} {claimsInChannel === 1 ? __('upload') : __('uploads')}
|
|
|
|
</span>
|
|
|
|
</>
|
|
|
|
)}
|
2021-03-17 21:53:35 +01:00
|
|
|
|
|
|
|
{!isChannel &&
|
2021-09-09 09:02:31 +02:00
|
|
|
(isLivestream && ENABLE_NO_SOURCE_CLAIMS ? (
|
|
|
|
__('Livestream')
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<FileViewCountInline uri={uri} isLivestream={isLivestream} />
|
|
|
|
<DateTime timeAgo uri={uri} />
|
|
|
|
</>
|
|
|
|
))}
|
2021-03-17 21:53:35 +01:00
|
|
|
</>
|
|
|
|
)}
|
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;
|