lbry-desktop/ui/component/channelDiscussion/index.js
2022-02-08 12:35:40 -05:00

25 lines
1 KiB
JavaScript

import { connect } from 'react-redux';
import { withRouter } from 'react-router';
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
import ChannelDiscussion from './view';
import { makeSelectTagInClaimOrChannelForUri, selectClaimForUri } from 'redux/selectors/claims';
import { selectSettingsByChannelId } from 'redux/selectors/comments';
import { getChannelIdFromClaim } from 'util/claim';
const select = (state, props) => {
const { search } = props.location;
const urlParams = new URLSearchParams(search);
const claim = selectClaimForUri(state, props.uri);
const channelId = getChannelIdFromClaim(claim);
const settingsByChannelId = selectSettingsByChannelId(state);
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
return {
linkedCommentId: urlParams.get('lc'),
commentsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
commentSettingDisabled: channelSettings && !channelSettings.comments_enabled,
};
};
export default withRouter(connect(select)(ChannelDiscussion));