lbry-desktop/ui/component/channelDiscussion/index.js

26 lines
1 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { withRouter } from 'react-router';
2021-02-05 00:00:07 +01:00
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
import ChannelDiscussion from './view';
2022-02-05 13:06:19 +01:00
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);
2022-02-05 13:06:19 +01:00
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'),
2021-02-05 00:00:07 +01:00
commentsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
2022-02-05 13:06:19 +01:00
commentSettingDisabled: channelSettings && !channelSettings.comments_enabled,
};
};
export default withRouter(connect(select)(ChannelDiscussion));