2017-12-21 22:08:54 +01:00
|
|
|
import { connect } from 'react-redux';
|
2021-11-16 05:23:18 +01:00
|
|
|
import { selectTitleForUri, selectClaimIsNsfwForUri, makeSelectClaimWasPurchased } from 'redux/selectors/claims';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { makeSelectFileInfoForUri, makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
|
2021-03-19 16:04:12 +01:00
|
|
|
import {
|
2021-09-10 19:27:21 +02:00
|
|
|
makeSelectNextUrlForCollectionAndUrl,
|
|
|
|
makeSelectPreviousUrlForCollectionAndUrl,
|
2021-10-17 10:36:14 +02:00
|
|
|
} from 'redux/selectors/collections';
|
|
|
|
import * as SETTINGS from 'constants/settings';
|
2020-01-06 21:57:49 +01:00
|
|
|
import {
|
2020-04-14 01:48:11 +02:00
|
|
|
makeSelectIsPlayerFloating,
|
2020-10-20 19:10:02 +02:00
|
|
|
selectPrimaryUri,
|
2020-01-06 21:57:49 +01:00
|
|
|
selectPlayingUri,
|
2020-04-01 20:43:50 +02:00
|
|
|
makeSelectFileRenderModeForUri,
|
2020-01-06 21:57:49 +01:00
|
|
|
} from 'redux/selectors/content';
|
2021-11-23 05:29:04 +01:00
|
|
|
import { selectClientSetting } from 'redux/selectors/settings';
|
2021-11-19 03:40:01 +01:00
|
|
|
import { selectCostInfoForUri } from 'lbryinc';
|
2021-09-10 19:27:21 +02:00
|
|
|
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
|
2021-03-19 16:04:12 +01:00
|
|
|
import { doFetchRecommendedContent } from 'redux/actions/search';
|
2021-09-10 19:27:21 +02:00
|
|
|
import { doAnaltyicsPurchaseEvent } from 'redux/actions/app';
|
2019-08-13 07:35:13 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2020-04-01 20:43:50 +02:00
|
|
|
import FileRenderFloating from './view';
|
2017-05-15 05:50:59 +02:00
|
|
|
|
2019-08-13 07:35:13 +02:00
|
|
|
const select = (state, props) => {
|
2020-04-29 22:50:06 +02:00
|
|
|
const playingUri = selectPlayingUri(state);
|
2020-10-20 19:10:02 +02:00
|
|
|
const primaryUri = selectPrimaryUri(state);
|
|
|
|
const uri = playingUri && playingUri.uri;
|
2021-09-02 22:05:32 +02:00
|
|
|
const collectionId = playingUri && playingUri.collectionId;
|
2020-10-20 19:10:02 +02:00
|
|
|
|
2019-08-13 07:35:13 +02:00
|
|
|
return {
|
|
|
|
uri,
|
2020-10-20 19:10:02 +02:00
|
|
|
primaryUri,
|
|
|
|
playingUri,
|
2021-11-16 05:23:18 +01:00
|
|
|
title: selectTitleForUri(state, uri),
|
2019-08-13 07:35:13 +02:00
|
|
|
fileInfo: makeSelectFileInfoForUri(uri)(state),
|
2021-11-16 02:10:03 +01:00
|
|
|
mature: selectClaimIsNsfwForUri(state, uri),
|
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),
|
2021-11-23 05:29:04 +01:00
|
|
|
floatingPlayerEnabled: selectClientSetting(state, SETTINGS.FLOATING_PLAYER),
|
2020-04-01 20:43:50 +02:00
|
|
|
renderMode: makeSelectFileRenderModeForUri(uri)(state),
|
2021-11-23 05:29:04 +01:00
|
|
|
videoTheaterMode: selectClientSetting(state, SETTINGS.VIDEO_THEATER_MODE),
|
2021-11-19 03:40:01 +01:00
|
|
|
costInfo: selectCostInfoForUri(state, uri),
|
2021-09-10 19:27:21 +02:00
|
|
|
claimWasPurchased: makeSelectClaimWasPurchased(uri)(state),
|
|
|
|
nextListUri: collectionId && makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state),
|
|
|
|
previousListUri: collectionId && makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state),
|
2021-09-02 22:05:32 +02:00
|
|
|
collectionId,
|
2019-08-13 07:35:13 +02:00
|
|
|
};
|
|
|
|
};
|
2017-04-23 11:56:50 +02:00
|
|
|
|
2021-03-19 16:04:12 +01:00
|
|
|
const perform = (dispatch) => ({
|
2020-10-20 19:10:02 +02:00
|
|
|
closeFloatingPlayer: () => dispatch(doSetPlayingUri({ uri: null })),
|
2021-03-19 16:04:12 +01:00
|
|
|
doFetchRecommendedContent: (uri, mature) => dispatch(doFetchRecommendedContent(uri, mature)),
|
2021-09-10 19:27:21 +02:00
|
|
|
doPlayUri: (uri, collectionId, hideFailModal) =>
|
|
|
|
dispatch(
|
|
|
|
doPlayUri(
|
|
|
|
uri,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
(fileInfo) => {
|
|
|
|
dispatch(doAnaltyicsPurchaseEvent(fileInfo));
|
|
|
|
},
|
|
|
|
hideFailModal
|
|
|
|
),
|
|
|
|
dispatch(doSetPlayingUri({ uri, collectionId }))
|
|
|
|
),
|
2021-09-24 17:53:17 +02:00
|
|
|
clearSecondarySource: (uri) => dispatch(doSetPlayingUri({ uri })),
|
2017-06-06 06:21:55 +02:00
|
|
|
});
|
2017-04-23 11:56:50 +02:00
|
|
|
|
2020-04-01 20:43:50 +02:00
|
|
|
export default withRouter(connect(select, perform)(FileRenderFloating));
|