2017-12-21 22:08:54 +01:00
|
|
|
import { connect } from 'react-redux';
|
2021-11-11 05:48:10 +01:00
|
|
|
import { selectClaimIsMine, selectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
|
2017-09-08 05:15:05 +02:00
|
|
|
import {
|
|
|
|
makeSelectFileInfoForUri,
|
|
|
|
makeSelectDownloadingForUri,
|
|
|
|
makeSelectLoadingForUri,
|
2020-05-21 17:38:28 +02:00
|
|
|
makeSelectStreamingUrlForUri,
|
2021-10-17 10:36:14 +02:00
|
|
|
} from 'redux/selectors/file_info';
|
2021-11-19 03:40:01 +01:00
|
|
|
import { selectCostInfoForUri } from 'lbryinc';
|
2022-02-01 21:11:35 +01:00
|
|
|
import { doOpenModal } from 'redux/actions/app';
|
|
|
|
import { doSetPlayingUri, doDownloadUri } from 'redux/actions/content';
|
2017-12-21 22:08:54 +01:00
|
|
|
import FileDownloadLink from './view';
|
2017-09-08 05:15:05 +02:00
|
|
|
|
2021-11-11 05:48:10 +01:00
|
|
|
const select = (state, props) => {
|
|
|
|
const claim = selectClaimForUri(state, props.uri);
|
|
|
|
|
|
|
|
return {
|
|
|
|
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
|
|
|
|
downloading: makeSelectDownloadingForUri(props.uri)(state),
|
|
|
|
loading: makeSelectLoadingForUri(props.uri)(state),
|
|
|
|
claimIsMine: selectClaimIsMine(state, claim),
|
|
|
|
claim,
|
2021-11-19 03:40:01 +01:00
|
|
|
costInfo: selectCostInfoForUri(state, props.uri),
|
2021-11-11 05:48:10 +01:00
|
|
|
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
|
|
|
|
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
|
|
|
|
};
|
|
|
|
};
|
2017-09-08 05:15:05 +02:00
|
|
|
|
2021-10-17 10:36:14 +02:00
|
|
|
const perform = (dispatch) => ({
|
2019-05-12 16:46:14 +02:00
|
|
|
openModal: (modal, props) => dispatch(doOpenModal(modal, props)),
|
2020-12-11 18:30:47 +01:00
|
|
|
pause: () => dispatch(doSetPlayingUri({ uri: null })),
|
2022-02-01 21:11:35 +01:00
|
|
|
download: (uri) => dispatch(doDownloadUri(uri)),
|
2017-09-08 05:15:05 +02:00
|
|
|
});
|
|
|
|
|
2020-05-21 17:38:28 +02:00
|
|
|
export default connect(select, perform)(FileDownloadLink);
|