lbry-desktop/src/ui/component/fileViewer/index.js

53 lines
2.1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import * as settings from 'constants/settings';
import { doChangeVolume } from 'redux/actions/app';
import { selectVolume } from 'redux/selectors/app';
import { doPlayUri, doSetPlayingUri, savePosition } from 'redux/actions/content';
2019-03-12 20:53:55 +01:00
import { doClaimEligiblePurchaseRewards, makeSelectCostInfoForUri } from 'lbryinc';
2017-05-15 05:50:59 +02:00
import {
2018-04-18 06:03:01 +02:00
makeSelectMetadataForUri,
makeSelectContentTypeForUri,
makeSelectClaimForUri,
2017-05-15 05:50:59 +02:00
makeSelectFileInfoForUri,
makeSelectLoadingForUri,
makeSelectDownloadingForUri,
2018-05-16 20:32:25 +02:00
selectSearchBarFocused,
makeSelectFirstRecommendedFileForUri,
2018-04-18 06:03:01 +02:00
} from 'lbry-redux';
2018-05-16 20:32:25 +02:00
import { makeSelectClientSetting, selectShowNsfw } from 'redux/selectors/settings';
import { selectPlayingUri, makeSelectContentPositionForUri } from 'redux/selectors/content';
import { selectFileInfoErrors } from 'redux/selectors/file_info';
2018-07-10 05:32:59 +02:00
import FileViewer from './view';
2017-05-15 05:50:59 +02:00
2017-09-08 05:15:05 +02:00
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
2017-09-08 05:15:05 +02:00
costInfo: makeSelectCostInfoForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
obscureNsfw: !selectShowNsfw(state),
isLoading: makeSelectLoadingForUri(props.uri)(state),
isDownloading: makeSelectDownloadingForUri(props.uri)(state),
playingUri: selectPlayingUri(state),
2017-09-08 05:15:05 +02:00
contentType: makeSelectContentTypeForUri(props.uri)(state),
volume: selectVolume(state),
2018-07-31 20:06:50 +02:00
position: makeSelectContentPositionForUri(props.uri)(state),
2018-05-16 20:32:25 +02:00
autoplay: makeSelectClientSetting(settings.AUTOPLAY)(state),
searchBarFocused: selectSearchBarFocused(state),
fileInfoErrors: selectFileInfoErrors(state),
nextFileToPlay: makeSelectFirstRecommendedFileForUri(props.uri)(state),
2017-09-08 05:15:05 +02:00
});
2017-04-23 11:56:50 +02:00
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
play: uri => dispatch(doPlayUri(uri)),
2017-09-18 04:13:05 +02:00
cancelPlay: () => dispatch(doSetPlayingUri(null)),
changeVolume: volume => dispatch(doChangeVolume(volume)),
claimRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
savePosition: (claimId, outpoint, position) =>
dispatch(savePosition(claimId, outpoint, position)),
2017-06-06 06:21:55 +02:00
});
2017-04-23 11:56:50 +02:00
2018-07-10 05:32:59 +02:00
export default connect(
select,
perform
)(FileViewer);