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

58 lines
1.6 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
2021-06-16 04:27:58 +02:00
import { makeSelectClaimIdForUri } from 'lbry-redux';
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';
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),
};
};
export default connect(select, {
doCommentModUnBlock,
doCommentModBlock,
2021-06-16 04:27:58 +02:00
doCommentModUnBlockAsAdmin,
doCommentModBlockAsAdmin,
doCommentModUnBlockAsModerator,
doCommentModBlockAsModerator,
})(ChannelBlockButton);