From e05b4a910f1108905bfe0837619547282e3eefea Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 25 Oct 2024 14:52:37 -0700 Subject: [PATCH] Conditionally render labels button when media exists in post (#5942) * conditionally render button * update labels on remove * tweak --- src/view/com/composer/Composer.tsx | 15 +- src/view/com/composer/labels/LabelsBtn.tsx | 229 +++++++++------------ src/view/com/composer/state/composer.ts | 15 ++ 3 files changed, 120 insertions(+), 139 deletions(-) diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index a523c3f523..af0326d908 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -896,13 +896,14 @@ function ComposerPills({ style={bottomBarAnimatedStyle} /> )} - { - dispatch({type: 'update_labels', labels: nextLabels}) - }} - hasMedia={hasMedia || hasLink} - /> + {hasMedia || hasLink ? ( + { + dispatch({type: 'update_labels', labels: nextLabels}) + }} + /> + ) : null} ) diff --git a/src/view/com/composer/labels/LabelsBtn.tsx b/src/view/com/composer/labels/LabelsBtn.tsx index bac2d756ac..fe8816fb43 100644 --- a/src/view/com/composer/labels/LabelsBtn.tsx +++ b/src/view/com/composer/labels/LabelsBtn.tsx @@ -21,11 +21,9 @@ import {Text} from '#/components/Typography' export function LabelsBtn({ labels, - hasMedia, onChange, }: { labels: SelfLabel[] - hasMedia: boolean onChange: (v: SelfLabel[]) => void }) { const control = Dialog.useDialogControl() @@ -45,10 +43,6 @@ export function LabelsBtn({ onChange([...filtered, newLabel].filter(Boolean) as SelfLabel[]) } - if (!hasMedia && hasLabel) { - onChange([]) - } - return ( <>