2017-12-21 18:08:54 -03:00
|
|
|
import { connect } from 'react-redux';
|
2020-10-20 13:10:02 -04:00
|
|
|
import { doSetContentHistoryItem, doSetPrimaryUri } from 'redux/actions/content';
|
2020-08-24 13:35:21 -04:00
|
|
|
import { withRouter } from 'react-router';
|
2021-01-08 10:21:27 -05:00
|
|
|
import {
|
|
|
|
doFetchFileInfo,
|
|
|
|
makeSelectFileInfoForUri,
|
|
|
|
makeSelectMetadataForUri,
|
|
|
|
makeSelectClaimIsNsfw,
|
|
|
|
SETTINGS,
|
2021-02-04 00:45:49 -05:00
|
|
|
makeSelectTagInClaimOrChannelForUri,
|
2021-03-29 19:05:18 -04:00
|
|
|
makeSelectClaimIsMine,
|
|
|
|
makeSelectClaimIsStreamPlaceholder,
|
2021-01-08 10:21:27 -05:00
|
|
|
} from 'lbry-redux';
|
2020-04-01 14:43:50 -04:00
|
|
|
import { makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc';
|
2021-01-08 10:21:27 -05:00
|
|
|
import { selectShowMatureContent, makeSelectClientSetting } from 'redux/selectors/settings';
|
2020-04-01 14:43:50 -04:00
|
|
|
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
|
2020-08-24 13:35:21 -04:00
|
|
|
import { makeSelectCommentForCommentId } from 'redux/selectors/comments';
|
2021-02-04 18:00:07 -05:00
|
|
|
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
|
|
|
|
|
2020-11-02 11:51:08 -05:00
|
|
|
import FilePage from './view';
|
2017-04-24 14:25:27 +07:00
|
|
|
|
2020-08-24 13:35:21 -04: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 10:21:27 -05:00
|
|
|
videoTheaterMode: makeSelectClientSetting(SETTINGS.VIDEO_THEATER_MODE)(state),
|
2021-02-04 18:00:07 -05:00
|
|
|
commentsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
2021-03-29 19:05:18 -04:00
|
|
|
claimIsMine: makeSelectClaimIsMine(props.uri)(state),
|
|
|
|
isLivestream: makeSelectClaimIsStreamPlaceholder(props.uri)(state),
|
2020-08-24 13:35:21 -04:00
|
|
|
};
|
|
|
|
};
|
2017-04-24 14:25:27 +07:00
|
|
|
|
2021-03-29 19:05:18 -04:00
|
|
|
const perform = (dispatch) => ({
|
|
|
|
fetchFileInfo: (uri) => dispatch(doFetchFileInfo(uri)),
|
|
|
|
fetchCostInfo: (uri) => dispatch(doFetchCostInfoForUri(uri)),
|
|
|
|
setViewed: (uri) => dispatch(doSetContentHistoryItem(uri)),
|
|
|
|
setPrimaryUri: (uri) => dispatch(doSetPrimaryUri(uri)),
|
2017-06-05 21:21:55 -07:00
|
|
|
});
|
2017-04-24 14:25:27 +07:00
|
|
|
|
2020-08-24 13:35:21 -04:00
|
|
|
export default withRouter(connect(select, perform)(FilePage));
|