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

55 lines
1.8 KiB
JavaScript
Raw Normal View History

2019-08-13 07:35:13 +02:00
import * as SETTINGS from 'constants/settings';
import { connect } from 'react-redux';
2017-05-15 05:50:59 +02:00
import {
makeSelectFileInfoForUri,
2019-04-24 16:02:08 +02:00
makeSelectThumbnailForUri,
2019-08-02 08:28:14 +02:00
makeSelectStreamingUrlForUri,
makeSelectMediaTypeForUri,
makeSelectContentTypeForUri,
2019-08-02 08:28:14 +02:00
makeSelectUriIsStreamable,
2019-08-13 07:35:13 +02:00
makeSelectTitleForUri,
2018-04-18 06:03:01 +02:00
} from 'lbry-redux';
import { doClaimEligiblePurchaseRewards } from 'lbryinc';
2020-01-06 21:57:49 +01:00
import {
makeSelectIsPlaying,
makeSelectShouldObscurePreview,
selectPlayingUri,
makeSelectIsText,
} from 'redux/selectors/content';
2019-08-13 07:35:13 +02:00
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { doSetPlayingUri } from 'redux/actions/content';
import { withRouter } from 'react-router';
2019-08-14 05:04:08 +02:00
import { doAnalyticsView } from 'redux/actions/app';
2018-07-10 05:32:59 +02:00
import FileViewer from './view';
2017-05-15 05:50:59 +02:00
2019-08-13 07:35:13 +02:00
const select = (state, props) => {
const uri = selectPlayingUri(state);
return {
uri,
title: makeSelectTitleForUri(uri)(state),
thumbnail: makeSelectThumbnailForUri(uri)(state),
mediaType: makeSelectMediaTypeForUri(uri)(state),
contentType: makeSelectContentTypeForUri(uri)(state),
2019-08-13 07:35:13 +02:00
fileInfo: makeSelectFileInfoForUri(uri)(state),
obscurePreview: makeSelectShouldObscurePreview(uri)(state),
isPlaying: makeSelectIsPlaying(uri)(state),
streamingUrl: makeSelectStreamingUrlForUri(uri)(state),
isStreamable: makeSelectUriIsStreamable(uri)(state),
floatingPlayerEnabled: makeSelectClientSetting(SETTINGS.FLOATING_PLAYER)(state),
2020-01-06 21:57:49 +01:00
isText: makeSelectIsText(uri)(state),
2019-08-13 07:35:13 +02:00
};
};
2017-04-23 11:56:50 +02:00
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
2019-08-13 07:35:13 +02:00
clearPlayingUri: () => dispatch(doSetPlayingUri(null)),
2019-08-14 05:04:08 +02:00
triggerAnalyticsView: (uri, timeToStart) => dispatch(doAnalyticsView(uri, timeToStart)),
claimRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
2017-06-06 06:21:55 +02:00
});
2017-04-23 11:56:50 +02:00
2019-08-13 07:35:13 +02:00
export default withRouter(
connect(
select,
perform
)(FileViewer)
);