From 71c1a8821ae9c0d2c6ddf8f40a1ccb640d5be067 Mon Sep 17 00:00:00 2001 From: jessop Date: Sat, 1 Feb 2020 16:17:20 -0500 Subject: [PATCH] reenable downloads --- static/app-strings.json | 5 +++-- ui/component/fileDownloadLink/view.jsx | 15 ++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/static/app-strings.json b/static/app-strings.json index 9e2a48e29..67e0ef012 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -921,5 +921,6 @@ "Your account": "Your account", "Channel profile picture": "Channel profile picture", "refreshing the app": "refreshing the app", - "Follower": "Follower" -} + "Follower": "Follower", + "%repost_channel_link% reposted": "%repost_channel_link% reposted" +} \ No newline at end of file diff --git a/ui/component/fileDownloadLink/view.jsx b/ui/component/fileDownloadLink/view.jsx index 76148b95a..bc9005d7b 100644 --- a/ui/component/fileDownloadLink/view.jsx +++ b/ui/component/fileDownloadLink/view.jsx @@ -1,8 +1,9 @@ // @flow import * as ICONS from 'constants/icons'; import * as MODALS from 'constants/modal_types'; -import React from 'react'; +import React, { useState } from 'react'; import Button from 'component/button'; +import { generateDownloadUrl } from 'util/lbrytv'; type Props = { uri: string, @@ -36,6 +37,8 @@ function FileDownloadLink(props: Props) { hideOpenButton = false, } = props; + const [viewEventSent, setViewEventSent] = useState(false); + const cost = costInfo ? Number(costInfo.cost) : 0; const isPaidContent = cost > 0; if (!claim || (IS_WEB && isPaidContent)) { @@ -44,16 +47,18 @@ function FileDownloadLink(props: Props) { const { name, claim_id: claimId, value } = claim; const fileName = value && value.source && value.source.name; - const downloadUrl = `/$/download/${name}/${claimId}`; + const downloadUrl = generateDownloadUrl(name, claimId); function handleDownload(e) { - e.preventDefault(); - // @if TARGET='app' + e.preventDefault(); download(uri); // @endif; // @if TARGET='web' - triggerViewEvent(uri); + if (!viewEventSent) { + triggerViewEvent(uri); + } + setViewEventSent(true); // @endif; }