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

56 lines
2.2 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 } from 'redux/actions/content';
2018-01-08 04:51:34 +01:00
import { doPlay, doPause, savePosition } from 'redux/actions/media';
import { doClaimEligiblePurchaseRewards } from 'redux/actions/rewards';
2017-05-15 05:50:59 +02:00
import {
2018-04-18 06:03:01 +02:00
makeSelectMetadataForUri,
makeSelectContentTypeForUri,
makeSelectCostInfoForUri,
makeSelectClaimForUri,
2017-05-15 05:50:59 +02:00
makeSelectFileInfoForUri,
makeSelectLoadingForUri,
makeSelectDownloadingForUri,
2018-05-16 20:32:25 +02:00
selectSearchBarFocused,
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';
2018-01-08 04:51:34 +01:00
import { selectMediaPaused, makeSelectMediaPositionForUri } from 'redux/selectors/media';
import { selectPlayingUri } 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),
2017-12-21 00:38:11 +01:00
mediaPaused: selectMediaPaused(state),
mediaPosition: makeSelectMediaPositionForUri(props.uri)(state),
2018-05-16 20:32:25 +02:00
autoplay: makeSelectClientSetting(settings.AUTOPLAY)(state),
searchBarFocused: selectSearchBarFocused(state),
fileInfoErrors: selectFileInfoErrors(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)),
2017-12-21 00:38:11 +01:00
doPlay: () => dispatch(doPlay()),
doPause: () => dispatch(doPause()),
2018-01-08 04:51:34 +01:00
savePosition: (claimId, position) => dispatch(savePosition(claimId, position)),
claimRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
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);