2019-10-15 00:21:40 +02:00
|
|
|
import { connect } from 'react-redux';
|
2020-08-31 19:12:34 +02:00
|
|
|
import { withRouter } from 'react-router';
|
2021-02-05 00:00:07 +01:00
|
|
|
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
|
2019-10-15 00:21:40 +02:00
|
|
|
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';
|
2019-10-15 00:21:40 +02:00
|
|
|
|
2020-08-31 19:12:34 +02:00
|
|
|
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;
|
|
|
|
|
2020-08-31 19:12:34 +02:00
|
|
|
return {
|
2021-07-15 16:43:28 +02:00
|
|
|
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,
|
2020-08-31 19:12:34 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withRouter(connect(select)(ChannelDiscussion));
|