2019-10-14 18:21:40 -04:00
|
|
|
import { connect } from 'react-redux';
|
2020-08-31 13:12:34 -04:00
|
|
|
import { withRouter } from 'react-router';
|
2021-02-04 18:00:07 -05:00
|
|
|
import { DISABLE_COMMENTS_TAG } from 'constants/tags';
|
2019-10-14 18:21:40 -04:00
|
|
|
import ChannelDiscussion from './view';
|
2022-02-05 09:06:19 -03:00
|
|
|
import { makeSelectTagInClaimOrChannelForUri, selectClaimForUri } from 'redux/selectors/claims';
|
|
|
|
import { selectSettingsByChannelId } from 'redux/selectors/comments';
|
|
|
|
import { getChannelIdFromClaim } from 'util/claim';
|
2019-10-14 18:21:40 -04:00
|
|
|
|
2020-08-31 13:12:34 -04:00
|
|
|
const select = (state, props) => {
|
|
|
|
const { search } = props.location;
|
|
|
|
const urlParams = new URLSearchParams(search);
|
|
|
|
|
2022-02-05 09:06:19 -03:00
|
|
|
const claim = selectClaimForUri(state, props.uri);
|
|
|
|
const channelId = getChannelIdFromClaim(claim);
|
|
|
|
const settingsByChannelId = selectSettingsByChannelId(state);
|
|
|
|
const channelSettings = channelId ? settingsByChannelId[channelId] : undefined;
|
|
|
|
|
2020-08-31 13:12:34 -04:00
|
|
|
return {
|
2021-07-15 22:43:28 +08:00
|
|
|
linkedCommentId: urlParams.get('lc'),
|
2021-02-04 18:00:07 -05:00
|
|
|
commentsDisabled: makeSelectTagInClaimOrChannelForUri(props.uri, DISABLE_COMMENTS_TAG)(state),
|
2022-02-05 09:06:19 -03:00
|
|
|
commentSettingDisabled: channelSettings && !channelSettings.comments_enabled,
|
2020-08-31 13:12:34 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withRouter(connect(select)(ChannelDiscussion));
|