From 38a916dcc406b660824ea5151db85e8c3091ba5f Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Fri, 11 Dec 2020 14:46:59 -0500 Subject: [PATCH] fix view_count getting called multiple times --- static/app-strings.json | 1 - ui/component/fileViewCount/view.jsx | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index 16c984711..4657b5af3 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -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.", "Deposit cannot be higher than your balance": "Deposit cannot be higher than your balance", "Your deposit must be higher": "Your deposit must be higher", - "%view_count% views": "%view_count% views", "1 view": "1 view", "Claiming...": "Claiming...", "Claim %amount% LBC": "Claim %amount% LBC", diff --git a/ui/component/fileViewCount/view.jsx b/ui/component/fileViewCount/view.jsx index 30c755bdf..fa0d2aab5 100644 --- a/ui/component/fileViewCount/view.jsx +++ b/ui/component/fileViewCount/view.jsx @@ -3,7 +3,7 @@ import React, { useEffect } from 'react'; import HelpLink from 'component/common/help-link'; type Props = { - claim: StreamClaim, + claim: ?StreamClaim, fetchViewCount: string => void, uri: string, viewCount: string, @@ -11,12 +11,13 @@ type Props = { function FileViewCount(props: Props) { const { claim, uri, fetchViewCount, viewCount } = props; + const claimId = claim && claim.claim_id; useEffect(() => { - if (claim && claim.claim_id) { - fetchViewCount(claim.claim_id); + if (claimId) { + fetchViewCount(claimId); } - }, [fetchViewCount, uri, claim]); + }, [fetchViewCount, uri, claimId]); const formattedViewCount = Number(viewCount).toLocaleString();