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

51 lines
2 KiB
JavaScript
Raw Normal View History

2019-08-13 07:35:13 +02:00
import { connect } from 'react-redux';
import { doPlayUri, doSetPlayingUri, doSetPrimaryUri } from 'redux/actions/content';
2020-05-21 17:38:28 +02:00
import {
makeSelectFileInfoForUri,
makeSelectThumbnailForUri,
makeSelectClaimForUri,
makeSelectStreamingUrlForUri,
makeSelectClaimWasPurchased,
SETTINGS,
2020-05-21 17:38:28 +02:00
} from 'lbry-redux';
import { makeSelectCostInfoForUri } from 'lbryinc';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
2019-08-13 07:35:13 +02:00
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { withRouter } from 'react-router';
import {
makeSelectIsPlaying,
makeSelectShouldObscurePreview,
selectPlayingUri,
makeSelectInsufficientCreditsForUri,
makeSelectFileRenderModeForUri,
} from 'redux/selectors/content';
import FileRenderInitiator from './view';
2020-05-21 17:38:28 +02:00
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
2019-08-13 07:35:13 +02:00
const select = (state, props) => ({
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
obscurePreview: makeSelectShouldObscurePreview(props.uri)(state),
isPlaying: makeSelectIsPlaying(props.uri)(state),
playingUri: selectPlayingUri(state),
insufficientCredits: makeSelectInsufficientCreditsForUri(props.uri)(state),
2020-05-21 17:38:28 +02:00
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
2019-08-13 07:35:13 +02:00
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
2019-08-29 01:33:38 +02:00
costInfo: makeSelectCostInfoForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
claim: makeSelectClaimForUri(props.uri)(state),
2020-05-21 17:38:28 +02:00
claimWasPurchased: makeSelectClaimWasPurchased(props.uri)(state),
authenticated: selectUserVerifiedEmail(state),
2019-08-13 07:35:13 +02:00
});
const perform = dispatch => ({
play: uri => {
dispatch(doSetPrimaryUri(uri));
dispatch(doSetPlayingUri({ uri }));
2020-05-21 17:38:28 +02:00
dispatch(doPlayUri(uri, undefined, undefined, fileInfo => dispatch(doAnaltyicsPurchaseEvent(fileInfo))));
2019-08-13 07:35:13 +02:00
},
});
export default withRouter(connect(select, perform)(FileRenderInitiator));