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

49 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-08-13 07:35:13 +02:00
import { connect } from 'react-redux';
import { doUriInitiatePlay, doSetPlayingUri } from 'redux/actions/content';
import { selectThumbnailForUri, selectClaimForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
import { makeSelectFileInfoForUri } from 'redux/selectors/file_info';
import * as SETTINGS from 'constants/settings';
import { selectCostInfoForUri } from 'lbryinc';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectClientSetting } from 'redux/selectors/settings';
import { withRouter } from 'react-router';
import {
makeSelectIsPlaying,
selectShouldObscurePreviewForUri,
selectInsufficientCreditsForUri,
makeSelectFileRenderModeForUri,
} from 'redux/selectors/content';
import FileRenderInitiator from './view';
import { getChannelIdFromClaim } from 'util/claim';
import { selectActiveLivestreamForChannel } from 'redux/selectors/livestream';
2019-08-13 07:35:13 +02:00
const select = (state, props) => {
const { uri } = props;
const claim = selectClaimForUri(state, uri);
const claimId = claim && claim.claim_id;
const channelClaimId = claim && getChannelIdFromClaim(claim);
return {
claimThumbnail: selectThumbnailForUri(state, uri),
fileInfo: makeSelectFileInfoForUri(uri)(state),
obscurePreview: selectShouldObscurePreviewForUri(state, uri),
isPlaying: makeSelectIsPlaying(uri)(state),
insufficientCredits: selectInsufficientCreditsForUri(state, uri),
autoplay: selectClientSetting(state, SETTINGS.AUTOPLAY_MEDIA),
costInfo: selectCostInfoForUri(state, uri),
renderMode: makeSelectFileRenderModeForUri(uri)(state),
claimWasPurchased: makeSelectClaimWasPurchased(uri)(state),
authenticated: selectUserVerifiedEmail(state),
activeLivestreamForChannel: channelClaimId && selectActiveLivestreamForChannel(state, channelClaimId),
claimId,
};
};
2019-08-13 07:35:13 +02:00
const perform = {
doUriInitiatePlay,
doSetPlayingUri,
};
2019-08-13 07:35:13 +02:00
export default withRouter(connect(select, perform)(FileRenderInitiator));