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

51 lines
1.6 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';
import { doPlayUri, doSetPlayingUri } from 'redux/actions/content';
import {
makeSelectFileInfoForUri,
makeSelectThumbnailForUri,
makeSelectStreamingUrlForUri,
makeSelectMediaTypeForUri,
makeSelectContentTypeForUri,
2019-08-13 07:35:13 +02:00
makeSelectUriIsStreamable,
} from 'lbry-redux';
import { makeSelectCostInfoForUri } from 'lbryinc';
2019-08-13 07:35:13 +02:00
import { makeSelectClientSetting } from 'redux/selectors/settings';
import {
makeSelectIsPlaying,
makeSelectShouldObscurePreview,
selectPlayingUri,
makeSelectCanAutoplay,
} from 'redux/selectors/content';
2019-08-13 07:35:13 +02:00
import FileViewer from './view';
const select = (state, props) => ({
thumbnail: makeSelectThumbnailForUri(props.uri)(state),
mediaType: makeSelectMediaTypeForUri(props.uri)(state),
contentType: makeSelectContentTypeForUri(props.uri)(state),
2019-08-13 07:35:13 +02:00
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
obscurePreview: makeSelectShouldObscurePreview(props.uri)(state),
isPlaying: makeSelectIsPlaying(props.uri)(state),
playingUri: selectPlayingUri(state),
streamingUrl: makeSelectStreamingUrlForUri(props.uri)(state),
isStreamable: makeSelectUriIsStreamable(props.uri)(state),
autoplay: makeSelectClientSetting(SETTINGS.AUTOPLAY)(state),
hasCostInfo: Boolean(makeSelectCostInfoForUri(props.uri)(state)),
2019-08-29 01:33:38 +02:00
costInfo: makeSelectCostInfoForUri(props.uri)(state),
isAutoPlayable: makeSelectCanAutoplay(props.uri)(state),
2019-08-13 07:35:13 +02:00
});
const perform = dispatch => ({
play: uri => {
dispatch(doSetPlayingUri(uri));
2019-08-13 22:54:57 +02:00
// @if TARGET='app'
2019-08-13 07:35:13 +02:00
dispatch(doPlayUri(uri));
2019-08-13 22:54:57 +02:00
// @endif
2019-08-13 07:35:13 +02:00
},
});
export default connect(
select,
perform
)(FileViewer);