make sure claim exists before showing download link

This commit is contained in:
Sean Yesmunt 2020-01-30 11:48:14 -05:00
parent 90bcfaa865
commit 4bb4d66852

View file

@ -35,8 +35,13 @@ function FileDownloadLink(props: Props) {
costInfo, costInfo,
hideOpenButton = false, hideOpenButton = false,
} = props; } = props;
const cost = costInfo ? Number(costInfo.cost) : 0; const cost = costInfo ? Number(costInfo.cost) : 0;
const isPaidContent = cost > 0; const isPaidContent = cost > 0;
if (!claim || (IS_WEB && isPaidContent)) {
return null;
}
const { name, claim_id: claimId, value } = claim; const { name, claim_id: claimId, value } = claim;
const fileName = value && value.source && value.source.name; const fileName = value && value.source && value.source.name;
const downloadUrl = `/$/download/${name}/${claimId}`; const downloadUrl = `/$/download/${name}/${claimId}`;
@ -52,10 +57,6 @@ function FileDownloadLink(props: Props) {
// @endif; // @endif;
} }
if (IS_WEB && isPaidContent) {
return null;
}
if (downloading || loading) { if (downloading || loading) {
const progress = fileInfo && fileInfo.written_bytes > 0 ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0; const progress = fileInfo && fileInfo.written_bytes > 0 ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0;
const label = const label =