From 4bb4d6685237e48556082a09ffeddcac820e9c05 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 30 Jan 2020 11:48:14 -0500 Subject: [PATCH] make sure claim exists before showing download link --- ui/component/fileDownloadLink/view.jsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/component/fileDownloadLink/view.jsx b/ui/component/fileDownloadLink/view.jsx index 9159a7db1..76148b95a 100644 --- a/ui/component/fileDownloadLink/view.jsx +++ b/ui/component/fileDownloadLink/view.jsx @@ -35,8 +35,13 @@ function FileDownloadLink(props: Props) { costInfo, hideOpenButton = false, } = props; + const cost = costInfo ? Number(costInfo.cost) : 0; const isPaidContent = cost > 0; + if (!claim || (IS_WEB && isPaidContent)) { + return null; + } + const { name, claim_id: claimId, value } = claim; const fileName = value && value.source && value.source.name; const downloadUrl = `/$/download/${name}/${claimId}`; @@ -52,10 +57,6 @@ function FileDownloadLink(props: Props) { // @endif; } - if (IS_WEB && isPaidContent) { - return null; - } - if (downloading || loading) { const progress = fileInfo && fileInfo.written_bytes > 0 ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0; const label =