2019-08-02 02:28:14 -04:00
|
|
|
import { connect } from 'react-redux';
|
2021-11-12 23:59:11 +08:00
|
|
|
import { makeSelectClaimForUri, selectThumbnailForUri } from 'redux/selectors/claims';
|
2021-09-02 17:05:32 -03:00
|
|
|
import {
|
|
|
|
makeSelectNextUrlForCollectionAndUrl,
|
|
|
|
makeSelectPreviousUrlForCollectionAndUrl,
|
2021-10-17 16:36:14 +08:00
|
|
|
} from 'redux/selectors/collections';
|
|
|
|
import * as SETTINGS from 'constants/settings';
|
|
|
|
import * as COLLECTIONS_CONSTS from 'constants/collections';
|
2021-09-10 14:27:21 -03:00
|
|
|
import {
|
|
|
|
doChangeVolume,
|
|
|
|
doChangeMute,
|
|
|
|
doAnalyticsView,
|
|
|
|
doAnalyticsBuffer,
|
|
|
|
doAnaltyicsPurchaseEvent,
|
|
|
|
} from 'redux/actions/app';
|
2019-08-02 02:28:14 -04:00
|
|
|
import { selectVolume, selectMute } from 'redux/selectors/app';
|
2021-09-02 17:05:32 -03:00
|
|
|
import { savePosition, clearPosition, doPlayUri, doSetPlayingUri } from 'redux/actions/content';
|
2021-09-16 17:00:44 -03:00
|
|
|
import { makeSelectContentPositionForUri, makeSelectIsPlayerFloating, selectPlayingUri } from 'redux/selectors/content';
|
2021-11-16 09:10:03 +08:00
|
|
|
import { selectRecommendedContentForUri } from 'redux/selectors/search';
|
2019-08-02 02:28:14 -04:00
|
|
|
import VideoViewer from './view';
|
2020-02-04 16:14:08 -05:00
|
|
|
import { withRouter } from 'react-router';
|
2020-06-15 16:33:03 -04:00
|
|
|
import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards';
|
2021-11-23 12:29:04 +08:00
|
|
|
import { selectDaemonSettings, selectClientSetting, selectHomepageData } from 'redux/selectors/settings';
|
2021-09-02 17:05:32 -03:00
|
|
|
import { toggleVideoTheaterMode, toggleAutoplayNext, doSetClientSetting } from 'redux/actions/settings';
|
2021-06-29 09:51:04 +08:00
|
|
|
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
|
2019-08-02 02:28:14 -04:00
|
|
|
|
2020-02-04 16:14:08 -05:00
|
|
|
const select = (state, props) => {
|
|
|
|
const { search } = props.location;
|
|
|
|
const urlParams = new URLSearchParams(search);
|
|
|
|
const autoplay = urlParams.get('autoplay');
|
2021-09-02 17:05:32 -03:00
|
|
|
const uri = props.uri;
|
2021-10-13 18:04:03 +03:00
|
|
|
|
2021-08-10 22:42:50 +02:00
|
|
|
// TODO: eventually this should be received from DB and not local state (https://github.com/lbryio/lbry-desktop/issues/6796)
|
2021-09-02 17:05:32 -03:00
|
|
|
const position = urlParams.get('t') !== null ? urlParams.get('t') : makeSelectContentPositionForUri(uri)(state);
|
2021-06-29 09:51:04 +08:00
|
|
|
const userId = selectUser(state) && selectUser(state).id;
|
2021-10-13 18:04:03 +03:00
|
|
|
const internalFeature = selectUser(state) && selectUser(state).internal_feature;
|
2021-09-02 17:05:32 -03:00
|
|
|
const playingUri = selectPlayingUri(state);
|
|
|
|
const collectionId = urlParams.get(COLLECTIONS_CONSTS.COLLECTION_ID) || (playingUri && playingUri.collectionId);
|
2021-09-13 12:24:35 -03:00
|
|
|
const isMarkdownOrComment = playingUri && (playingUri.source === 'markdown' || playingUri.source === 'comment');
|
2021-09-02 17:05:32 -03:00
|
|
|
|
|
|
|
let nextRecommendedUri;
|
|
|
|
let previousListUri;
|
|
|
|
if (collectionId) {
|
|
|
|
nextRecommendedUri = makeSelectNextUrlForCollectionAndUrl(collectionId, uri)(state);
|
|
|
|
previousListUri = makeSelectPreviousUrlForCollectionAndUrl(collectionId, uri)(state);
|
|
|
|
} else {
|
2021-11-16 09:10:03 +08:00
|
|
|
const recommendedContent = selectRecommendedContentForUri(state, uri);
|
2021-09-16 17:00:44 -03:00
|
|
|
nextRecommendedUri = recommendedContent && recommendedContent[0];
|
2021-09-02 17:05:32 -03:00
|
|
|
}
|
2020-03-19 16:25:37 -04:00
|
|
|
|
2020-02-04 16:14:08 -05:00
|
|
|
return {
|
2021-09-13 12:24:35 -03:00
|
|
|
position,
|
|
|
|
userId,
|
2021-10-13 18:04:03 +03:00
|
|
|
internalFeature,
|
2021-09-13 12:24:35 -03:00
|
|
|
collectionId,
|
|
|
|
nextRecommendedUri,
|
|
|
|
previousListUri,
|
|
|
|
isMarkdownOrComment,
|
2020-04-13 19:48:11 -04:00
|
|
|
autoplayIfEmbedded: Boolean(autoplay),
|
2021-11-23 12:29:04 +08:00
|
|
|
autoplayNext: selectClientSetting(state, SETTINGS.AUTOPLAY_NEXT),
|
2020-02-04 16:14:08 -05:00
|
|
|
volume: selectVolume(state),
|
|
|
|
muted: selectMute(state),
|
2021-11-23 12:29:04 +08:00
|
|
|
videoPlaybackRate: selectClientSetting(state, SETTINGS.VIDEO_PLAYBACK_RATE),
|
2021-11-12 23:59:11 +08:00
|
|
|
thumbnail: selectThumbnailForUri(state, uri),
|
2021-09-02 17:05:32 -03:00
|
|
|
claim: makeSelectClaimForUri(uri)(state),
|
2021-04-12 12:43:47 -04:00
|
|
|
homepageData: selectHomepageData(state),
|
|
|
|
authenticated: selectUserVerifiedEmail(state),
|
2021-07-31 11:55:02 +08:00
|
|
|
shareTelemetry: IS_WEB || selectDaemonSettings(state).share_usage_data,
|
2021-09-02 17:05:32 -03:00
|
|
|
isFloating: makeSelectIsPlayerFloating(props.location)(state),
|
2021-11-23 12:29:04 +08:00
|
|
|
videoTheaterMode: selectClientSetting(state, SETTINGS.VIDEO_THEATER_MODE),
|
2020-02-04 16:14:08 -05:00
|
|
|
};
|
|
|
|
};
|
2019-08-02 02:28:14 -04:00
|
|
|
|
2021-04-12 12:43:47 -04:00
|
|
|
const perform = (dispatch) => ({
|
|
|
|
changeVolume: (volume) => dispatch(doChangeVolume(volume)),
|
2019-08-13 01:35:13 -04:00
|
|
|
savePosition: (uri, position) => dispatch(savePosition(uri, position)),
|
2021-04-12 12:43:47 -04:00
|
|
|
clearPosition: (uri) => dispatch(clearPosition(uri)),
|
|
|
|
changeMute: (muted) => dispatch(doChangeMute(muted)),
|
2020-04-13 19:48:11 -04:00
|
|
|
doAnalyticsView: (uri, timeToStart) => dispatch(doAnalyticsView(uri, timeToStart)),
|
2020-08-07 16:59:20 -04:00
|
|
|
doAnalyticsBuffer: (uri, bufferData) => dispatch(doAnalyticsBuffer(uri, bufferData)),
|
2020-04-13 19:48:11 -04:00
|
|
|
claimRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
|
2021-01-08 10:21:27 -05:00
|
|
|
toggleVideoTheaterMode: () => dispatch(toggleVideoTheaterMode()),
|
2021-09-02 17:05:32 -03:00
|
|
|
toggleAutoplayNext: () => dispatch(toggleAutoplayNext()),
|
2021-04-12 12:43:47 -04:00
|
|
|
setVideoPlaybackRate: (rate) => dispatch(doSetClientSetting(SETTINGS.VIDEO_PLAYBACK_RATE, rate)),
|
2021-09-10 14:27:21 -03:00
|
|
|
doPlayUri: (uri, collectionId) =>
|
|
|
|
dispatch(
|
|
|
|
doPlayUri(
|
|
|
|
uri,
|
|
|
|
false,
|
|
|
|
false,
|
|
|
|
(fileInfo) => {
|
|
|
|
dispatch(doAnaltyicsPurchaseEvent(fileInfo));
|
|
|
|
},
|
|
|
|
true
|
|
|
|
),
|
|
|
|
dispatch(doSetPlayingUri({ uri, collectionId }))
|
|
|
|
),
|
2019-08-02 02:28:14 -04:00
|
|
|
});
|
|
|
|
|
2020-03-19 16:25:37 -04:00
|
|
|
export default withRouter(connect(select, perform)(VideoViewer));
|