2019-08-13 07:35:13 +02:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
|
2020-05-21 17:38:28 +02:00
|
|
|
import {
|
|
|
|
makeSelectFileInfoForUri,
|
|
|
|
makeSelectThumbnailForUri,
|
|
|
|
makeSelectClaimForUri,
|
|
|
|
makeSelectStreamingUrlForUri,
|
|
|
|
makeSelectClaimWasPurchased,
|
2020-07-10 23:04:36 +02:00
|
|
|
SETTINGS,
|
2020-05-21 17:38:28 +02:00
|
|
|
} from 'lbry-redux';
|
2020-06-15 22:33:03 +02:00
|
|
|
import { makeSelectCostInfoForUri } from 'lbryinc';
|
|
|
|
import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
2019-08-13 07:35:13 +02:00
|
|
|
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
2020-04-01 20:43:50 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2019-12-10 20:45:41 +01:00
|
|
|
import {
|
|
|
|
makeSelectIsPlaying,
|
|
|
|
makeSelectShouldObscurePreview,
|
|
|
|
selectPlayingUri,
|
2020-04-01 20:43:50 +02:00
|
|
|
makeSelectInsufficientCreditsForUri,
|
|
|
|
makeSelectFileRenderModeForUri,
|
2019-12-10 20:45:41 +01:00
|
|
|
} from 'redux/selectors/content';
|
2020-04-01 20:43:50 +02:00
|
|
|
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),
|
2020-04-01 20:43:50 +02:00
|
|
|
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),
|
2019-08-19 20:15:54 +02:00
|
|
|
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
|
2019-08-29 01:33:38 +02:00
|
|
|
costInfo: makeSelectCostInfoForUri(props.uri)(state),
|
2020-04-01 20:43:50 +02:00
|
|
|
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
|
2020-01-13 19:33:07 +01:00
|
|
|
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(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
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-04-01 20:43:50 +02:00
|
|
|
export default withRouter(connect(select, perform)(FileRenderInitiator));
|