lbry-desktop/ui/page/file/index.js

46 lines
1.8 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { doSetContentHistoryItem, doSetPrimaryUri } from 'redux/actions/content';
2020-08-24 19:35:21 +02:00
import { withRouter } from 'react-router';
2021-01-08 16:21:27 +01:00
import {
doFetchFileInfo,
makeSelectFileInfoForUri,
makeSelectMetadataForUri,
makeSelectClaimIsNsfw,
SETTINGS,
2021-02-04 06:45:49 +01:00
makeSelectTagInClaimOrChannelForUri,
2021-01-08 16:21:27 +01:00
} from 'lbry-redux';
import { makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc';
2021-01-08 16:21:27 +01:00
import { selectShowMatureContent, makeSelectClientSetting } from 'redux/selectors/settings';
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
2020-08-24 19:35:21 +02:00
import { makeSelectCommentForCommentId } from 'redux/selectors/comments';
2021-02-05 00:00:07 +01:00
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
2020-11-02 17:51:08 +01:00
import FilePage from './view';
2020-08-24 19:35:21 +02:00
const select = (state, props) => {
const { search } = props.location;
const urlParams = new URLSearchParams(search);
const linkedCommentId = urlParams.get('lc');
return {
linkedComment: makeSelectCommentForCommentId(linkedCommentId)(state),
costInfo: makeSelectCostInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
obscureNsfw: !selectShowMatureContent(state),
isMature: makeSelectClaimIsNsfw(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
2021-01-08 16:21:27 +01:00
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
2021-02-05 00:00:07 +01:00
commentsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
2020-08-24 19:35:21 +02:00
};
};
2017-06-06 06:21:55 +02:00
const perform = dispatch => ({
2017-06-06 23:19:12 +02:00
fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)),
fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)),
setViewed: uri => dispatch(doSetContentHistoryItem(uri)),
setPrimaryUri: uri => dispatch(doSetPrimaryUri(uri)),
2017-06-06 06:21:55 +02:00
});
2020-08-24 19:35:21 +02:00
export default withRouter(connect(select, perform)(FilePage));