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

71 lines
2.5 KiB
JavaScript
Raw Permalink Normal View History

import { connect } from 'react-redux';
import {
makeSelectFileInfoForUri,
makeSelectTitleForUri,
makeSelectStreamingUrlForUri,
makeSelectClaimIsNsfw,
makeSelectClaimWasPurchased,
makeSelectNextUrlForCollectionAndUrl,
makeSelectPreviousUrlForCollectionAndUrl,
SETTINGS,
} from 'lbry-redux';
2020-01-06 21:57:49 +01:00
import {
2020-04-14 01:48:11 +02:00
makeSelectIsPlayerFloating,
selectPrimaryUri,
2020-01-06 21:57:49 +01:00
selectPlayingUri,
makeSelectFileRenderModeForUri,
2020-01-06 21:57:49 +01:00
} from 'redux/selectors/content';
2019-08-13 07:35:13 +02:00
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectCostInfoForUri } from 'lbryinc';
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
import { doFetchRecommendedContent } from 'redux/actions/search';
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
2019-08-13 07:35:13 +02:00
import { withRouter } from 'react-router';
import FileRenderFloating from './view';
2017-05-15 05:50:59 +02:00
2019-08-13 07:35:13 +02:00
const select = (state, props) => {
const playingUri = selectPlayingUri(state);
const primaryUri = selectPrimaryUri(state);
const uri = playingUri && playingUri.uri;
const collectionId = playingUri && playingUri.collectionId;
2019-08-13 07:35:13 +02:00
return {
uri,
primaryUri,
playingUri,
2019-08-13 07:35:13 +02:00
title: makeSelectTitleForUri(uri)(state),
fileInfo: makeSelectFileInfoForUri(uri)(state),
mature: makeSelectClaimIsNsfw(uri)(state),
2020-04-14 01:48:11 +02:00
isFloating: makeSelectIsPlayerFloating(props.location)(state),
2020-05-21 17:38:28 +02:00
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
2019-08-13 07:35:13 +02:00
floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
renderMode: makeSelectFileRenderModeForUri(uri)(state),
2021-01-08 16:21:27 +01:00
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
costInfo: makeSelectCostInfoForUri(uri)(state),
claimWasPurchased: makeSelectClaimWasPurchased(uri)(state),
nextListUri: collectionId && makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state),
previousListUri: collectionId && makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state),
collectionId,
2019-08-13 07:35:13 +02:00
};
};
2017-04-23 11:56:50 +02:00
const perform = (dispatch) => ({
closeFloatingPlayer: () => dispatch(doSetPlayingUri({ uri: null })),
doFetchRecommendedContent: (uri, mature) => dispatch(doFetchRecommendedContent(uri, mature)),
doPlayUri: (uri, collectionId, hideFailModal) =>
dispatch(
doPlayUri(
uri,
false,
false,
(fileInfo) => {
dispatch(doAnaltyicsPurchaseEvent(fileInfo));
},
hideFailModal
),
dispatch(doSetPlayingUri({ uri, collectionId }))
),
2017-06-06 06:21:55 +02:00
});
2017-04-23 11:56:50 +02:00
export default withRouter(connect(select, perform)(FileRenderFloating));