mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-28 16:01:26 +00:00
triggers analytic on download click + completed
This commit is contained in:
parent
723d1fabbb
commit
ba4d6afde0
1 changed files with 4 additions and 6 deletions
|
@ -19,13 +19,10 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function FileDownloadLink(props: 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;
|
const { fileInfo, downloading, loading, openModal, pause, claimIsMine, download, uri, triggerAnalyticsView } = props;
|
||||||
|
|
||||||
if (downloading || loading) {
|
if (downloading || loading) {
|
||||||
if (!shouldTrigger) {
|
|
||||||
setShouldTrigger(true);
|
|
||||||
}
|
|
||||||
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 =
|
||||||
fileInfo && fileInfo.written_bytes > 0 ? progress.toFixed(0) + __('% downloaded') : __('Connecting...');
|
fileInfo && fileInfo.written_bytes > 0 ? progress.toFixed(0) + __('% downloaded') : __('Connecting...');
|
||||||
|
@ -33,9 +30,9 @@ function FileDownloadLink(props: Props) {
|
||||||
return <span>{label}</span>;
|
return <span>{label}</span>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileInfo && fileInfo.download_path && fileInfo.completed && shouldTrigger) {
|
if (fileInfo && fileInfo.download_path && fileInfo.completed && clicked) {
|
||||||
triggerAnalyticsView(uri, 0);
|
triggerAnalyticsView(uri, 0);
|
||||||
setShouldTrigger(false);
|
setClicked(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fileInfo && fileInfo.download_path && fileInfo.completed) {
|
if (fileInfo && fileInfo.download_path && fileInfo.completed) {
|
||||||
|
@ -58,6 +55,7 @@ function FileDownloadLink(props: Props) {
|
||||||
button="link"
|
button="link"
|
||||||
icon={ICONS.DOWNLOAD}
|
icon={ICONS.DOWNLOAD}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
setClicked(true);
|
||||||
download(uri);
|
download(uri);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue