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

43 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-08-13 07:35:13 +02:00
import * as SETTINGS from 'constants/settings';
import { connect } from 'react-redux';
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
import { makeSelectFileInfoForUri, makeSelectThumbnailForUri, makeSelectClaimForUri } from 'lbry-redux';
import { makeSelectCostInfoForUri } from 'lbryinc';
2019-08-13 07:35:13 +02:00
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { withRouter } from 'react-router';
import {
makeSelectIsPlaying,
makeSelectShouldObscurePreview,
selectPlayingUri,
makeSelectInsufficientCreditsForUri,
makeSelectStreamingUrlForUriWebProxy,
makeSelectFileRenderModeForUri,
} from 'redux/selectors/content';
import FileRenderInitiator from './view';
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),
streamingUrl: makeSelectStreamingUrlForUriWebProxy(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),
2019-08-13 07:35:13 +02:00
});
const perform = dispatch => ({
play: uri => {
dispatch(doSetPlayingUri(uri));
2019-08-13 22:54:57 +02:00
// @if TARGET='app'
2019-08-13 07:35:13 +02:00
dispatch(doPlayUri(uri));
2019-08-13 22:54:57 +02:00
// @endif
2019-08-13 07:35:13 +02:00
},
});
export default withRouter(connect(select, perform)(FileRenderInitiator));