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

35 lines
1.2 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { selectClaimIsMine, selectClaimForUri } 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,
} from 'redux/selectors/file_info';
import { selectCostInfoForUri } from 'lbryinc';
import { doOpenModal } from 'redux/actions/app';
import { doSetPlayingUri, doDownloadUri } from 'redux/actions/content';
import FileDownloadLink from './view';
2017-09-08 05:15:05 +02: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,
costInfo: selectCostInfoForUri(state, props.uri),
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(doDownloadUri(uri)),
2017-09-08 05:15:05 +02:00
});
2020-05-21 17:38:28 +02:00
export default connect(select, perform)(FileDownloadLink);