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

76 lines
2.9 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
2022-03-23 19:24:16 +01:00
import {
selectClaimForUri,
selectTitleForUri,
makeSelectClaimWasPurchased,
selectGeoRestrictionForUri,
} from 'redux/selectors/claims';
import { makeSelectStreamingUrlForUri } from 'redux/selectors/file_info';
import {
makeSelectNextUrlForCollectionAndUrl,
makeSelectPreviousUrlForCollectionAndUrl,
} 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,
selectPrimaryUri,
2020-01-06 21:57:49 +01:00
selectPlayingUri,
makeSelectFileRenderModeForUri,
2020-01-06 21:57:49 +01:00
} from 'redux/selectors/content';
import { selectClientSetting } from 'redux/selectors/settings';
import { selectCostInfoForUri } from 'lbryinc';
import { doUriInitiatePlay, doSetPlayingUri } from 'redux/actions/content';
import { doFetchRecommendedContent } from 'redux/actions/search';
2019-08-13 07:35:13 +02:00
import { withRouter } from 'react-router';
import { selectAppDrawerOpen } from 'redux/selectors/app';
import { selectIsActiveLivestreamForUri, selectCommentSocketConnected } from 'redux/selectors/livestream';
import { doCommentSocketConnect, doCommentSocketDisconnect } from 'redux/actions/websocket';
import { isStreamPlaceholderClaim, getVideoClaimAspectRatio } from 'util/claim';
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 { location } = props;
const playingUri = selectPlayingUri(state);
const { uri, collectionId } = playingUri || {};
const claim = uri && selectClaimForUri(state, uri);
const { claim_id: claimId, signing_channel: channelClaim } = claim || {};
2022-03-16 12:35:58 +01:00
const { canonical_url: channelUrl } = channelClaim || {};
2019-08-13 07:35:13 +02:00
return {
claimId,
2022-03-16 12:35:58 +01:00
channelUrl,
2019-08-13 07:35:13 +02:00
uri,
playingUri,
primaryUri: selectPrimaryUri(state),
title: selectTitleForUri(state, uri),
isFloating: makeSelectIsPlayerFloating(location)(state),
2020-05-21 17:38:28 +02:00
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
floatingPlayerEnabled: selectClientSetting(state, SETTINGS.FLOATING_PLAYER),
renderMode: makeSelectFileRenderModeForUri(uri)(state),
videoTheaterMode: selectClientSetting(state, SETTINGS.VIDEO_THEATER_MODE),
costInfo: selectCostInfoForUri(state, uri),
claimWasPurchased: makeSelectClaimWasPurchased(uri)(state),
nextListUri: collectionId && makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state),
previousListUri: collectionId && makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state),
collectionId,
isCurrentClaimLive: selectIsActiveLivestreamForUri(state, uri),
videoAspectRatio: getVideoClaimAspectRatio(claim),
socketConnected: selectCommentSocketConnected(state),
2022-03-15 17:48:57 +01:00
isLivestreamClaim: isStreamPlaceholderClaim(claim),
2022-03-23 19:24:16 +01:00
geoRestriction: selectGeoRestrictionForUri(state, uri),
appDrawerOpen: selectAppDrawerOpen(state),
2019-08-13 07:35:13 +02:00
};
};
2017-04-23 11:56:50 +02:00
const perform = {
doFetchRecommendedContent,
doUriInitiatePlay,
doSetPlayingUri,
doCommentSocketConnect,
doCommentSocketDisconnect,
};
2017-04-23 11:56:50 +02:00
export default withRouter(connect(select, perform)(FileRenderFloating));