2021-03-03 19:50:16 +01:00
|
|
|
import { connect } from 'react-redux';
|
2021-10-17 10:36:14 +02:00
|
|
|
import { makeSelectClaimIdForUri } from 'redux/selectors/claims';
|
2021-06-16 04:27:58 +02:00
|
|
|
import {
|
|
|
|
doCommentModUnBlock,
|
|
|
|
doCommentModBlock,
|
|
|
|
doCommentModBlockAsAdmin,
|
|
|
|
doCommentModUnBlockAsAdmin,
|
|
|
|
doCommentModUnBlockAsModerator,
|
|
|
|
doCommentModBlockAsModerator,
|
|
|
|
} from 'redux/actions/comments';
|
|
|
|
import {
|
|
|
|
makeSelectChannelIsBlocked,
|
|
|
|
makeSelectChannelIsAdminBlocked,
|
|
|
|
makeSelectChannelIsModeratorBlockedForCreator,
|
|
|
|
makeSelectUriIsBlockingOrUnBlocking,
|
|
|
|
makeSelectIsTogglingForDelegator,
|
|
|
|
} from 'redux/selectors/comments';
|
|
|
|
|
|
|
|
import { BLOCK_LEVEL } from 'constants/comment';
|
2021-03-03 19:50:16 +01:00
|
|
|
import ChannelBlockButton from './view';
|
|
|
|
|
2021-06-16 04:27:58 +02:00
|
|
|
const select = (state, props) => {
|
|
|
|
let isBlocked;
|
|
|
|
let isToggling;
|
|
|
|
|
|
|
|
switch (props.blockLevel) {
|
|
|
|
default:
|
|
|
|
case BLOCK_LEVEL.SELF:
|
|
|
|
isBlocked = makeSelectChannelIsBlocked(props.uri)(state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_LEVEL.MODERATOR:
|
|
|
|
isBlocked = makeSelectChannelIsModeratorBlockedForCreator(props.uri, props.creatorUri)(state);
|
|
|
|
isToggling = makeSelectIsTogglingForDelegator(props.uri, props.creatorUri)(state);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BLOCK_LEVEL.ADMIN:
|
|
|
|
isBlocked = makeSelectChannelIsAdminBlocked(props.uri)(state);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
isBlocked,
|
|
|
|
isToggling,
|
|
|
|
isBlockingOrUnBlocking: makeSelectUriIsBlockingOrUnBlocking(props.uri)(state),
|
|
|
|
creatorId: makeSelectClaimIdForUri(props.creatorUri)(state),
|
|
|
|
};
|
|
|
|
};
|
2021-03-03 19:50:16 +01:00
|
|
|
|
|
|
|
export default connect(select, {
|
|
|
|
doCommentModUnBlock,
|
|
|
|
doCommentModBlock,
|
2021-06-16 04:27:58 +02:00
|
|
|
doCommentModUnBlockAsAdmin,
|
|
|
|
doCommentModBlockAsAdmin,
|
|
|
|
doCommentModUnBlockAsModerator,
|
|
|
|
doCommentModBlockAsModerator,
|
2021-03-03 19:50:16 +01:00
|
|
|
})(ChannelBlockButton);
|