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