fix view_count getting called multiple times

This commit is contained in:
Sean Yesmunt 2020-12-11 14:46:59 -05:00
parent 6ac3b0d6cd
commit 38a916dcc4
2 changed files with 5 additions and 5 deletions

View file

@ -700,7 +700,6 @@
"A %site_name% account allows you to earn more than %credit_amount% in rewards, backup your data, and get content and security updates.": "A %site_name% account allows you to earn more than %credit_amount% in rewards, backup your data, and get content and security updates.", "A %site_name% account allows you to earn more than %credit_amount% in rewards, backup your data, and get content and security updates.": "A %site_name% account allows you to earn more than %credit_amount% in rewards, backup your data, and get content and security updates.",
"Deposit cannot be higher than your balance": "Deposit cannot be higher than your balance", "Deposit cannot be higher than your balance": "Deposit cannot be higher than your balance",
"Your deposit must be higher": "Your deposit must be higher", "Your deposit must be higher": "Your deposit must be higher",
"%view_count% views": "%view_count% views",
"1 view": "1 view", "1 view": "1 view",
"Claiming...": "Claiming...", "Claiming...": "Claiming...",
"Claim %amount% LBC": "Claim %amount% LBC", "Claim %amount% LBC": "Claim %amount% LBC",

View file

@ -3,7 +3,7 @@ import React, { useEffect } from 'react';
import HelpLink from 'component/common/help-link'; import HelpLink from 'component/common/help-link';
type Props = { type Props = {
claim: StreamClaim, claim: ?StreamClaim,
fetchViewCount: string => void, fetchViewCount: string => void,
uri: string, uri: string,
viewCount: string, viewCount: string,
@ -11,12 +11,13 @@ type Props = {
function FileViewCount(props: Props) { function FileViewCount(props: Props) {
const { claim, uri, fetchViewCount, viewCount } = props; const { claim, uri, fetchViewCount, viewCount } = props;
const claimId = claim && claim.claim_id;
useEffect(() => { useEffect(() => {
if (claim && claim.claim_id) { if (claimId) {
fetchViewCount(claim.claim_id); fetchViewCount(claimId);
} }
}, [fetchViewCount, uri, claim]); }, [fetchViewCount, uri, claimId]);
const formattedViewCount = Number(viewCount).toLocaleString(); const formattedViewCount = Number(viewCount).toLocaleString();