2017-12-21 22:08:54 +01:00
|
|
|
import { connect } from 'react-redux';
|
2018-04-30 17:27:20 +02:00
|
|
|
import * as settings from 'constants/settings';
|
2017-12-21 22:08:54 +01:00
|
|
|
import { doChangeVolume } from 'redux/actions/app';
|
|
|
|
import { selectVolume } from 'redux/selectors/app';
|
2018-07-31 14:36:20 +02:00
|
|
|
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,
|
2019-01-28 21:05:28 +01:00
|
|
|
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';
|
2018-07-31 14:36:20 +02:00
|
|
|
import { selectPlayingUri, makeSelectContentPositionForUri } from 'redux/selectors/content';
|
2018-07-12 21:37:01 +02:00
|
|
|
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) => ({
|
2017-12-29 17:07:03 +01:00
|
|
|
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),
|
2017-09-18 04:08:43 +02:00
|
|
|
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),
|
2018-08-28 22:46:50 +02:00
|
|
|
fileInfoErrors: selectFileInfoErrors(state),
|
2019-01-28 21:05:28 +01:00
|
|
|
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 => ({
|
2017-09-18 04:08:43 +02:00
|
|
|
play: uri => dispatch(doPlayUri(uri)),
|
2017-09-18 04:13:05 +02:00
|
|
|
cancelPlay: () => dispatch(doSetPlayingUri(null)),
|
2017-08-25 21:05:00 +02:00
|
|
|
changeVolume: volume => dispatch(doChangeVolume(volume)),
|
2018-08-30 05:35:49 +02:00
|
|
|
claimRewards: () => dispatch(doClaimEligiblePurchaseRewards()),
|
2018-07-31 14:36:20 +02:00
|
|
|
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);
|