lbry-desktop/ui/component/claimPreviewSubtitle/view.jsx

62 lines
1.7 KiB
React
Raw Permalink Normal View History

// @flow
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 'util/lbryURI';
2022-04-26 17:28:23 +02:00
import { formatNumber } from 'util/number';
type Props = {
uri: string,
claim: ?Claim,
pending?: boolean,
type: string,
2021-10-14 22:46:36 +02:00
beginPublish: (?string) => void,
};
// previews used in channel overview and homepage (and other places?)
2020-01-30 23:25:15 +01:00
function ClaimPreviewSubtitle(props: Props) {
2021-10-19 06:49:51 +02: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 />{' '}
2021-03-17 21:53:35 +01:00
{!pending && claim && (
<>
{isChannel &&
type !== 'inline' &&
2022-04-26 17:28:23 +02:00
`${formatNumber(claimsInChannel, 2, true)} ${claimsInChannel === 1 ? __('upload') : __('uploads')}`}
2021-03-17 21:53:35 +01:00
2021-10-19 06:49:51 +02:00
{!isChannel && (
<>
<FileViewCountInline uri={uri} />
<DateTime timeAgo uri={uri} />
</>
)}
2021-03-17 21:53:35 +01:00
</>
)}
</React.Fragment>
) : (
<React.Fragment>
2020-07-23 19:02:07 +02:00
<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>
);
}
2020-01-30 23:25:15 +01:00
export default ClaimPreviewSubtitle;