diff --git a/ui/component/fileDownloadLink/view.jsx b/ui/component/fileDownloadLink/view.jsx index 72e8de03a..40f43575d 100644 --- a/ui/component/fileDownloadLink/view.jsx +++ b/ui/component/fileDownloadLink/view.jsx @@ -19,13 +19,10 @@ type Props = { }; function FileDownloadLink(props: Props) { - const [shouldTrigger, setShouldTrigger] = useState(false); + const [clicked, setClicked] = useState(false); const { fileInfo, downloading, loading, openModal, pause, claimIsMine, download, uri, triggerAnalyticsView } = props; if (downloading || loading) { - if (!shouldTrigger) { - setShouldTrigger(true); - } const progress = fileInfo && fileInfo.written_bytes > 0 ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0; const label = fileInfo && fileInfo.written_bytes > 0 ? progress.toFixed(0) + __('% downloaded') : __('Connecting...'); @@ -33,9 +30,9 @@ function FileDownloadLink(props: Props) { return {label}; } - if (fileInfo && fileInfo.download_path && fileInfo.completed && shouldTrigger) { + if (fileInfo && fileInfo.download_path && fileInfo.completed && clicked) { triggerAnalyticsView(uri, 0); - setShouldTrigger(false); + setClicked(false); } if (fileInfo && fileInfo.download_path && fileInfo.completed) { @@ -58,6 +55,7 @@ function FileDownloadLink(props: Props) { button="link" icon={ICONS.DOWNLOAD} onClick={() => { + setClicked(true); download(uri); }} />