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.
30 lines
937 B
JavaScript
30 lines
937 B
JavaScript
// @flow
|
|
import React from 'react';
|
|
|
|
type Props = {
|
|
uri: string,
|
|
isLivestream?: boolean,
|
|
// --- select ---
|
|
claim: ?StreamClaim,
|
|
viewCount: string,
|
|
};
|
|
|
|
export default function FileViewCountInline(props: Props) {
|
|
const { isLivestream, claim, viewCount } = props;
|
|
const formattedViewCount = Number(viewCount).toLocaleString();
|
|
|
|
if (!viewCount || (claim && claim.repost_url) || isLivestream) {
|
|
// (1) Currently, makeSelectViewCountForUri doesn't differentiate between
|
|
// unfetched view-count vs zero view-count. But since it's probably not
|
|
// ideal to highlight that a view has 0 count, let's just not show anything.
|
|
// (2) No idea how to get the repost src's claim ID from the repost claim,
|
|
// so hiding it for now.
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<span className="view_count">
|
|
{viewCount !== 1 ? __('%view_count% views', { view_count: formattedViewCount }) : __('1 view')}
|
|
</span>
|
|
);
|
|
}
|