From 5e63d3164b58552f81b597eff83cba991bea958e Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Wed, 16 Aug 2023 10:46:52 -0700 Subject: [PATCH] A set of composer fixes (#1187) * Don't insert a newline on cmd+entrl (close #1173) * Don't linkify selected text on url-paste (close #1149) * Disable the adult content controls if there is no media on the post (close #1169) --- src/state/models/ui/shell.ts | 1 + src/view/com/composer/Composer.tsx | 3 +- src/view/com/composer/labels/LabelsBtn.tsx | 9 +- .../com/composer/text-input/TextInput.web.tsx | 2 + src/view/com/modals/SelfLabel.tsx | 93 +++++++++++-------- 5 files changed, 66 insertions(+), 42 deletions(-) diff --git a/src/state/models/ui/shell.ts b/src/state/models/ui/shell.ts index e5fd5d42..92d028c7 100644 --- a/src/state/models/ui/shell.ts +++ b/src/state/models/ui/shell.ts @@ -102,6 +102,7 @@ export interface RepostModal { export interface SelfLabelModal { name: 'self-label' labels: string[] + hasMedia: boolean onChange: (labels: string[]) => void } diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index f9629797..fe9cc834 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -218,6 +218,7 @@ export const ComposePost = observer(function ComposePost({ const selectTextInputPlaceholder = replyTo ? 'Write your reply' : `What's up?` const canSelectImages = useMemo(() => gallery.size < 4, [gallery.size]) + const hasMedia = gallery.size > 0 || Boolean(extLink) return ( Cancel - + {isProcessing ? ( diff --git a/src/view/com/composer/labels/LabelsBtn.tsx b/src/view/com/composer/labels/LabelsBtn.tsx index 1abcbe03..96908d47 100644 --- a/src/view/com/composer/labels/LabelsBtn.tsx +++ b/src/view/com/composer/labels/LabelsBtn.tsx @@ -11,9 +11,11 @@ import {isNative} from 'platform/detection' export const LabelsBtn = observer(function LabelsBtn({ labels, + hasMedia, onChange, }: { labels: string[] + hasMedia: boolean onChange: (v: string[]) => void }) { const pal = usePalette('default') @@ -23,7 +25,7 @@ export const LabelsBtn = observer(function LabelsBtn({ ) : null} - - toggleAdultLabel('sexual')} - accessibilityHint="" - style={s.flex1} - /> - toggleAdultLabel('nudity')} - accessibilityHint="" - style={s.flex1} - /> - toggleAdultLabel('porn')} - accessibilityHint="" - style={s.flex1} - /> - + {hasMedia ? ( + <> + + toggleAdultLabel('sexual')} + accessibilityHint="" + style={s.flex1} + /> + toggleAdultLabel('nudity')} + accessibilityHint="" + style={s.flex1} + /> + toggleAdultLabel('porn')} + accessibilityHint="" + style={s.flex1} + /> + - - {selected.includes('sexual') ? ( - <>Pictures meant for adults. - ) : selected.includes('nudity') ? ( - <>Artistic or non-erotic nudity. - ) : selected.includes('porn') ? ( - <>Sexual activity or erotic nudity. - ) : ( - <>If none are selected, suitable for all ages. - )} - + + {selected.includes('sexual') ? ( + <>Pictures meant for adults. + ) : selected.includes('nudity') ? ( + <>Artistic or non-erotic nudity. + ) : selected.includes('porn') ? ( + <>Sexual activity or erotic nudity. + ) : ( + <>If none are selected, suitable for all ages. + )} + + + ) : ( + + + + Not Applicable + + . This warning is only available for posts with media attached. + + + )}