093c427b83
## Issue 3587 Show content view counts on channel pages ## Notes Limited to just "channel pages" for now as specified in the ticket. Can be enabled for all claim previews, as long as there's an efficient spot to run the batch fetching. Either make `fetchViewCount` prop default to true, or add the parameter in places that need it.
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
// @flow
|
|
import { ENABLE_NO_SOURCE_CLAIMS } from 'config';
|
|
import React from 'react';
|
|
import UriIndicator from 'component/uriIndicator';
|
|
import DateTime from 'component/dateTime';
|
|
import Button from 'component/button';
|
|
import FileViewCountInline from 'component/fileViewCountInline';
|
|
import { parseURI } from 'lbry-redux';
|
|
|
|
type Props = {
|
|
uri: string,
|
|
claim: ?Claim,
|
|
pending?: boolean,
|
|
type: string,
|
|
beginPublish: (string) => void,
|
|
isLivestream: boolean,
|
|
};
|
|
|
|
function ClaimPreviewSubtitle(props: Props) {
|
|
const { pending, uri, claim, type, beginPublish, isLivestream } = 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 />{' '}
|
|
{!pending && claim && (
|
|
<>
|
|
{isChannel &&
|
|
type !== 'inline' &&
|
|
`${claimsInChannel} ${claimsInChannel === 1 ? __('upload') : __('uploads')}`}
|
|
|
|
{!isChannel &&
|
|
(isLivestream && ENABLE_NO_SOURCE_CLAIMS ? (
|
|
__('Livestream')
|
|
) : (
|
|
<>
|
|
<FileViewCountInline uri={uri} isLivestream={isLivestream} />
|
|
<DateTime timeAgo uri={uri} />
|
|
</>
|
|
))}
|
|
</>
|
|
)}
|
|
</React.Fragment>
|
|
) : (
|
|
<React.Fragment>
|
|
<div>{__('Upload something and claim this spot!')}</div>
|
|
<div className="card__actions">
|
|
<Button onClick={() => beginPublish(name)} button="primary" label={__('Publish to %uri%', { uri })} />
|
|
</div>
|
|
</React.Fragment>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default ClaimPreviewSubtitle;
|