From ec594e7c96b1273ee3e11d526fd2ea4bb33b4dff Mon Sep 17 00:00:00 2001 From: danidfra Date: Thu, 25 Jul 2024 17:02:32 -0300 Subject: [PATCH 1/2] Hidden blocks button --- src/components/status-action-bar.tsx | 12 +++-- src/features/account/components/header.tsx | 38 ++++++++------- src/features/settings/index.tsx | 2 +- .../ui/components/modals/actions-modal.tsx | 46 +++++++++---------- 4 files changed, 52 insertions(+), 46 deletions(-) diff --git a/src/components/status-action-bar.tsx b/src/components/status-action-bar.tsx index 1e7737781..f4005a7b2 100644 --- a/src/components/status-action-bar.tsx +++ b/src/components/status-action-bar.tsx @@ -558,11 +558,13 @@ const StatusActionBar: React.FC = ({ action: handleMuteClick, icon: require('@tabler/icons/outline/volume-3.svg'), }); - menu.push({ - text: intl.formatMessage(messages.block, { name: username }), - action: handleBlockClick, - icon: require('@tabler/icons/outline/ban.svg'), - }); + if (features.blocks) { + menu.push({ + text: intl.formatMessage(messages.block, { name: username }), + action: handleBlockClick, + icon: require('@tabler/icons/outline/ban.svg'), + }); + } menu.push({ text: intl.formatMessage(messages.report, { name: username }), action: handleReport, diff --git a/src/features/account/components/header.tsx b/src/features/account/components/header.tsx index 786ce40c9..c5e361f6c 100644 --- a/src/features/account/components/header.tsx +++ b/src/features/account/components/header.tsx @@ -371,11 +371,13 @@ const Header: React.FC = ({ account }) => { to: '/mutes', icon: require('@tabler/icons/outline/circle-x.svg'), }); - menu.push({ - text: intl.formatMessage(messages.blocks), - to: '/blocks', - icon: require('@tabler/icons/outline/ban.svg'), - }); + if (features.blocks) { + menu.push({ + text: intl.formatMessage(messages.blocks), + to: '/blocks', + icon: require('@tabler/icons/outline/ban.svg'), + }); + } } else { menu.push({ text: intl.formatMessage(messages.mention, { name: account.username }), @@ -453,18 +455,20 @@ const Header: React.FC = ({ account }) => { }); } - if (account.relationship?.blocking) { - menu.push({ - text: intl.formatMessage(messages.unblock, { name: account.username }), - action: onBlock, - icon: require('@tabler/icons/outline/ban.svg'), - }); - } else { - menu.push({ - text: intl.formatMessage(messages.block, { name: account.username }), - action: onBlock, - icon: require('@tabler/icons/outline/ban.svg'), - }); + if (features.blocks) { + if (account.relationship?.blocking) { + menu.push({ + text: intl.formatMessage(messages.unblock, { name: account.username }), + action: onBlock, + icon: require('@tabler/icons/outline/ban.svg'), + }); + } else { + menu.push({ + text: intl.formatMessage(messages.block, { name: account.username }), + action: onBlock, + icon: require('@tabler/icons/outline/ban.svg'), + }); + } } menu.push({ diff --git a/src/features/settings/index.tsx b/src/features/settings/index.tsx index c3b26376f..51fcbcbbc 100644 --- a/src/features/settings/index.tsx +++ b/src/features/settings/index.tsx @@ -85,7 +85,7 @@ const Settings = () => { - + {features.blocks && ()} diff --git a/src/features/ui/components/modals/actions-modal.tsx b/src/features/ui/components/modals/actions-modal.tsx index 5fd37bab7..3b73f0a5f 100644 --- a/src/features/ui/components/modals/actions-modal.tsx +++ b/src/features/ui/components/modals/actions-modal.tsx @@ -23,30 +23,30 @@ const ActionsModal: React.FC = ({ status, actions, onClick, onClo const renderAction = (action: MenuItem | null, i: number) => { if (action === null) { return
  • ; - } - - const { icon = null, text, meta = null, active = false, href = '#', destructive } = action; + } else if (action.text !== 'Blocks') { + const { icon = null, text, meta = null, active = false, href = '#', destructive } = action; + + const Comp = href === '#' ? 'button' : 'a'; + const compProps = href === '#' ? { onClick: onClick } : { href: href, rel: 'noopener' }; - const Comp = href === '#' ? 'button' : 'a'; - const compProps = href === '#' ? { onClick: onClick } : { href: href, rel: 'noopener' }; - - return ( -
  • - - {icon && } -
    -
    {text}
    -
    {meta}
    -
    -
    -
  • - ); + return ( +
  • + + {icon && } +
    +
    {text}
    +
    {meta}
    +
    +
    +
  • + ); + } }; return ( From 28defb4b09381d575110af5ad6532f5b95e42e27 Mon Sep 17 00:00:00 2001 From: danidfra Date: Thu, 25 Jul 2024 18:28:45 -0300 Subject: [PATCH 2/2] Remove else conditional --- .../ui/components/modals/actions-modal.tsx | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/features/ui/components/modals/actions-modal.tsx b/src/features/ui/components/modals/actions-modal.tsx index 3b73f0a5f..5fd37bab7 100644 --- a/src/features/ui/components/modals/actions-modal.tsx +++ b/src/features/ui/components/modals/actions-modal.tsx @@ -23,30 +23,30 @@ const ActionsModal: React.FC = ({ status, actions, onClick, onClo const renderAction = (action: MenuItem | null, i: number) => { if (action === null) { return
  • ; - } else if (action.text !== 'Blocks') { - const { icon = null, text, meta = null, active = false, href = '#', destructive } = action; - - const Comp = href === '#' ? 'button' : 'a'; - const compProps = href === '#' ? { onClick: onClick } : { href: href, rel: 'noopener' }; - - return ( -
  • - - {icon && } -
    -
    {text}
    -
    {meta}
    -
    -
    -
  • - ); } + + const { icon = null, text, meta = null, active = false, href = '#', destructive } = action; + + const Comp = href === '#' ? 'button' : 'a'; + const compProps = href === '#' ? { onClick: onClick } : { href: href, rel: 'noopener' }; + + return ( +
  • + + {icon && } +
    +
    {text}
    +
    {meta}
    +
    +
    +
  • + ); }; return (