2021-03-03 19:50:16 +01:00
|
|
|
import { connect } from 'react-redux';
|
2021-12-31 18:52:26 +01:00
|
|
|
import { selectClaimIdForUri } 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),
|
2021-12-31 18:52:26 +01:00
|
|
|
creatorId: selectClaimIdForUri(state, props.creatorUri),
|
2021-06-16 04:27:58 +02:00
|
|
|
};
|
|
|
|
};
|
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);
|