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

45 lines
1.8 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
2018-10-19 22:38:07 +02:00
import { doRemoveUnreadSubscription } from 'redux/actions/subscriptions';
import { doSetContentHistoryItem } from 'redux/actions/content';
2020-08-24 19:35:21 +02:00
import { withRouter } from 'react-router';
2017-04-28 17:14:44 +02:00
import {
2018-04-18 06:03:01 +02:00
doFetchFileInfo,
makeSelectFileInfoForUri,
2017-05-15 05:50:59 +02:00
makeSelectMetadataForUri,
2018-10-19 22:38:07 +02:00
makeSelectChannelForClaimUri,
makeSelectClaimIsNsfw,
2018-04-18 06:03:01 +02:00
} from 'lbry-redux';
import { makeSelectCostInfoForUri, doFetchCostInfoForUri } from 'lbryinc';
2020-01-06 19:32:35 +01:00
import { selectShowMatureContent } from 'redux/selectors/settings';
2018-10-19 22:38:07 +02:00
import { makeSelectIsSubscribed } from 'redux/selectors/subscriptions';
import { makeSelectFileRenderModeForUri } from 'redux/selectors/content';
import FilePage from './view';
2020-08-24 19:35:21 +02:00
import { makeSelectCommentForCommentId } from 'redux/selectors/comments';
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),
isSubscribed: makeSelectIsSubscribed(props.uri)(state),
channelUri: makeSelectChannelForClaimUri(props.uri, true)(state),
renderMode: makeSelectFileRenderModeForUri(props.uri)(state),
};
};
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)),
2018-10-19 22:38:07 +02:00
markSubscriptionRead: (channel, uri) => dispatch(doRemoveUnreadSubscription(channel, uri)),
2017-06-06 06:21:55 +02:00
});
2020-08-24 19:35:21 +02:00
export default withRouter(connect(select, perform)(FilePage));