diff --git a/ui/component/fileDownloadLink/index.js b/ui/component/fileDownloadLink/index.js
index 7372829e9..2d079ed89 100644
--- a/ui/component/fileDownloadLink/index.js
+++ b/ui/component/fileDownloadLink/index.js
@@ -19,8 +19,7 @@ const select = (state, props) => ({
const perform = dispatch => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
pause: () => dispatch(doSetPlayingUri(null)),
- download: uri => dispatch(doPlayUri(uri, false, true)),
- triggerAnalyticsView: (uri, timeToStart) => dispatch(doAnalyticsView(uri, timeToStart)),
+ download: uri => dispatch(doPlayUri(uri, false, true, () => dispatch(doAnalyticsView(uri)))),
});
export default connect(
diff --git a/ui/component/fileDownloadLink/view.jsx b/ui/component/fileDownloadLink/view.jsx
index 81856225b..226d92a36 100644
--- a/ui/component/fileDownloadLink/view.jsx
+++ b/ui/component/fileDownloadLink/view.jsx
@@ -1,7 +1,7 @@
// @flow
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
-import React, { useState } from 'react';
+import React from 'react';
import Button from 'component/button';
import ToolTip from 'component/common/tooltip';
@@ -15,12 +15,10 @@ type Props = {
openModal: (id: string, { path: string }) => void,
pause: () => void,
download: string => void,
- triggerAnalyticsView: (string, number) => void,
};
function FileDownloadLink(props: Props) {
- 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 } = props;
if (downloading || loading) {
const progress = fileInfo && fileInfo.written_bytes > 0 ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0;
@@ -30,11 +28,6 @@ function FileDownloadLink(props: Props) {
return {label};
}
- if (fileInfo && fileInfo.download_path && clicked) {
- triggerAnalyticsView(uri, 0);
- setClicked(false);
- }
-
if (fileInfo && fileInfo.download_path && fileInfo.completed) {
return (
@@ -55,7 +48,6 @@ function FileDownloadLink(props: Props) {
button="link"
icon={ICONS.DOWNLOAD}
onClick={() => {
- setClicked(true);
download(uri);
}}
/>
diff --git a/ui/redux/actions/content.js b/ui/redux/actions/content.js
index e50d7f9ca..e1e6eb3da 100644
--- a/ui/redux/actions/content.js
+++ b/ui/redux/actions/content.js
@@ -179,19 +179,28 @@ export function doFetchClaimsByChannel(uri: string, page: number = 1, pageSize:
};
}
-export function doPurchaseUriWrapper(uri: string, cost: number, saveFile: boolean) {
+export function doPurchaseUriWrapper(uri: string, cost: number, saveFile: boolean, cb: ?() => void) {
return (dispatch: Dispatch, getState: () => any) => {
function onSuccess(fileInfo) {
- dispatch(doUpdateLoadStatus(uri, fileInfo.outpoint));
+ if (saveFile) {
+ dispatch(doUpdateLoadStatus(uri, fileInfo.outpoint));
+ }
+
+ if (cb) {
+ cb();
+ }
}
- // Only pass the success callback if we are saving the file, otherwise we don't show the download percentage
- const successCallBack = saveFile ? onSuccess : undefined;
- dispatch(doPurchaseUri(uri, { costInfo: cost }, saveFile, successCallBack));
+ dispatch(doPurchaseUri(uri, { costInfo: cost }, saveFile, onSuccess));
};
}
-export function doPlayUri(uri: string, skipCostCheck: boolean = false, saveFileOverride: boolean = false) {
+export function doPlayUri(
+ uri: string,
+ skipCostCheck: boolean = false,
+ saveFileOverride: boolean = false,
+ cb?: () => void
+) {
return (dispatch: Dispatch, getState: () => any) => {
const state = getState();
const fileInfo = makeSelectFileInfoForUri(uri)(state);
@@ -211,7 +220,7 @@ export function doPlayUri(uri: string, skipCostCheck: boolean = false, saveFileO
const instantPurchaseMax = makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state);
function beginGetFile() {
- dispatch(doPurchaseUriWrapper(uri, cost, saveFile));
+ dispatch(doPurchaseUriWrapper(uri, cost, saveFile, cb));
}
function attemptPlay(instantPurchaseMax = null) {