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

30 lines
667 B
React
Raw Normal View History

2020-01-06 19:32:35 +01:00
// @flow
import React, { useEffect } from 'react';
2020-01-06 19:32:35 +01:00
import HelpLink from 'component/common/help-link';
type Props = {
claim: StreamClaim,
fetchViewCount: string => void,
uri: string,
2020-01-06 19:32:35 +01:00
viewCount: string,
};
2020-01-06 21:57:49 +01:00
function FileViewCount(props: Props) {
const { claim, uri, fetchViewCount, viewCount } = props;
useEffect(() => {
if (claim && claim.claim_id) {
fetchViewCount(claim.claim_id);
}
}, [fetchViewCount, uri, claim]);
2020-01-06 19:32:35 +01:00
return (
<span>
{viewCount !== 1 ? __('%view_count% Views', { view_count: viewCount }) : __('1 View')}
<HelpLink href="https://lbry.com/faq/views" />
</span>
);
}
2020-01-06 21:57:49 +01:00
export default FileViewCount;