lbry-desktop/ui/component/fileDownloadLink/index.js

34 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

import { connect } from 'react-redux';
2017-09-08 05:15:05 +02:00
import {
makeSelectFileInfoForUri,
makeSelectDownloadingForUri,
makeSelectLoadingForUri,
makeSelectClaimIsMine,
2020-01-07 19:17:43 +01:00
makeSelectClaimForUri,
2020-05-21 17:38:28 +02:00
makeSelectClaimWasPurchased,
makeSelectStreamingUrlForUri,
2018-04-18 06:03:01 +02:00
} from 'lbry-redux';
import { makeSelectCostInfoForUri } from 'lbryinc';
2019-11-04 18:09:11 +01:00
import { doOpenModal, doAnalyticsView } from 'redux/actions/app';
2019-08-06 05:25:33 +02:00
import { doSetPlayingUri, doPlayUri } from 'redux/actions/content';
import FileDownloadLink from './view';
2017-09-08 05:15:05 +02:00
const select = (state, props) => ({
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
downloading: makeSelectDownloadingForUri(props.uri)(state),
loading: makeSelectLoadingForUri(props.uri)(state),
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
2020-01-07 19:17:43 +01:00
claim: makeSelectClaimForUri(props.uri)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
2020-05-21 17:38:28 +02:00
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
2017-09-08 05:15:05 +02:00
});
const perform = dispatch => ({
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
pause: () => dispatch(doSetPlayingUri({ uri: null })),
download: uri => dispatch(doPlayUri(uri, false, true, () => dispatch(doAnalyticsView(uri)))),
2017-09-08 05:15:05 +02:00
});
2020-05-21 17:38:28 +02:00
export default connect(select, perform)(FileDownloadLink);