lbry-desktop/ui/component/fileViewCount/view.jsx
TigerxWood 8099088415 Made uniform display of text views
Too many forms of word "views" and "view" to translate, with caps and without. We need to choose the same in all places.
2020-06-09 09:26:41 -04:00

31 lines
742 B
JavaScript

// @flow
import React, { useEffect } from 'react';
import HelpLink from 'component/common/help-link';
type Props = {
claim: StreamClaim,
fetchViewCount: string => void,
uri: string,
viewCount: string,
};
function FileViewCount(props: Props) {
const { claim, uri, fetchViewCount, viewCount } = props;
useEffect(() => {
if (claim && claim.claim_id) {
fetchViewCount(claim.claim_id);
}
}, [fetchViewCount, uri, claim]);
const formattedViewCount = Number(viewCount).toLocaleString();
return (
<span>
{viewCount !== 1 ? __('%view_count% views', { view_count: formattedViewCount }) : __('1 view')}
<HelpLink href="https://lbry.com/faq/views" />
</span>
);
}
export default FileViewCount;