diff --git a/ui/modal/modalBlockChannel/view.jsx b/ui/modal/modalBlockChannel/view.jsx index d15e7b9cf..454f1a370 100644 --- a/ui/modal/modalBlockChannel/view.jsx +++ b/ui/modal/modalBlockChannel/view.jsx @@ -71,21 +71,26 @@ export default function ModalBlockChannel(props: Props) { const [timeoutInputErr, setTimeoutInputErr] = React.useState(''); const [timeoutSec, setTimeoutSec] = React.useState(-1); - const personalIsTheOnlyTab = !activeChannelIsModerator && !activeChannelIsAdmin; + const isPersonalTheOnlyTab = !activeChannelIsModerator && !activeChannelIsAdmin; + const isTimeoutAvail = contentClaim && contentClaim.is_my_output; const blockButtonDisabled = blockType === BLOCK.TIMEOUT && timeoutSec < 1; // ************************************************************************** // ************************************************************************** - // Check 'tab' validity on mount. + // Check settings validity on mount. React.useEffect(() => { if ( - personalIsTheOnlyTab || + isPersonalTheOnlyTab || (tab === TAB.MODERATOR && !activeChannelIsModerator) || (tab === TAB.ADMIN && !activeChannelIsAdmin) ) { setTab(TAB.PERSONAL); } + + if (!isTimeoutAvail && blockType === BLOCK.TIMEOUT) { + setBlockType(BLOCK.PERMANENT); + } }, []); // eslint-disable-line react-hooks/exhaustive-deps // 'timeoutInput' to 'timeoutSec' conversion. @@ -154,13 +159,14 @@ export default function ModalBlockChannel(props: Props) { } } - function getBlockTypeElem(value, label) { + function getBlockTypeElem(value, label, disabled = false, disabledLabel = '') { return ( setBlockType(value)} /> @@ -239,6 +245,13 @@ export default function ModalBlockChannel(props: Props) { // ************************************************************************** // ************************************************************************** + if (isPersonalTheOnlyTab && !isTimeoutAvail) { + // There's only 1 option. Just execute it and don't show the modal. + commentModBlock(commenterUri); + closeModal(); + return null; + } + return ( - {!personalIsTheOnlyTab && ( + {!isPersonalTheOnlyTab && (
@@ -265,7 +278,12 @@ export default function ModalBlockChannel(props: Props) {
{getBlockTypeElem(BLOCK.PERMANENT, 'Permanent')} - {getBlockTypeElem(BLOCK.TIMEOUT, 'Timeout --[time-based ban instead of permanent]--')} + {getBlockTypeElem( + BLOCK.TIMEOUT, + 'Timeout --[time-based ban instead of permanent]--', + !isTimeoutAvail, + 'Timeout (only available on content that you own)' + )}
{blockType === BLOCK.TIMEOUT && getTimeoutDurationElem()}