From f9e988c5fb36a9bcebc25a4909e9a288c7a5ff78 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Fri, 9 Aug 2024 11:37:20 -0500 Subject: [PATCH] Some renaming --- src/components/WhoCanReply.tsx | 30 +++++----- src/components/dialogs/ThreadgateEditor.tsx | 55 +++++++++---------- src/state/queries/postgate/index.ts | 1 - .../com/composer/threadgate/ThreadgateBtn.tsx | 4 +- 4 files changed, 43 insertions(+), 47 deletions(-) diff --git a/src/components/WhoCanReply.tsx b/src/components/WhoCanReply.tsx index c9fca6ba69..824a8de2cb 100644 --- a/src/components/WhoCanReply.tsx +++ b/src/components/WhoCanReply.tsx @@ -65,14 +65,11 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) { } const isEverybody = settings.length === 0 - const isNobody = !!settings.find(gate => gate.type === 'nobody') const description = isEverybody - ? _(msg`Everybody can reply`) - : isNobody - ? _(msg`Replies disabled`) - : _(msg`Some people can reply`) + ? _(msg`Anyone can interact`) + : _(msg`Interaction limited`) - const onPressEdit = () => { + const onPress = () => { if (isNative && Keyboard.isVisible()) { Keyboard.dismiss() } @@ -129,7 +126,7 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) { label={ isThreadAuthor ? _(msg`Edit who can reply`) : _(msg`Who can reply`) } - onPress={isThreadAuthor ? onPressEdit : infoDialogControl.open} + onPress={onPress} hitSlop={HITSLOP_10}> {({hovered}) => ( @@ -147,22 +144,25 @@ export function WhoCanReply({post, isThreadAuthor, style}: WhoCanReplyProps) { ]}> {description} + {isThreadAuthor && ( )} )} - - {isThreadAuthor && ( + + {isThreadAuthor ? ( + ) : ( + )} diff --git a/src/components/dialogs/ThreadgateEditor.tsx b/src/components/dialogs/ThreadgateEditor.tsx index 1f9d754e93..ddd3a35e95 100644 --- a/src/components/dialogs/ThreadgateEditor.tsx +++ b/src/components/dialogs/ThreadgateEditor.tsx @@ -12,56 +12,53 @@ import * as Dialog from '#/components/Dialog' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {Text} from '#/components/Typography' -interface ThreadgateEditorDialogProps { - control: Dialog.DialogControlProps - threadgate: ThreadgateAllowUISetting[] - onChange?: (v: ThreadgateAllowUISetting[]) => void - onConfirm?: (v: ThreadgateAllowUISetting[]) => void +type Props = { + threadgateUISettings: ThreadgateAllowUISetting[] + onChangeThreadgateUISettings?: (v: ThreadgateAllowUISetting[]) => void + onConfirmThreadgateUISettings?: (v: ThreadgateAllowUISetting[]) => void } export function ThreadgateEditorDialog({ control, - threadgate, - onChange, - onConfirm, -}: ThreadgateEditorDialogProps) { + onChangeThreadgateUISettings, + onConfirmThreadgateUISettings, + threadgateUISettings, +}: Props & { + control: Dialog.DialogControlProps +}) { return ( ) } function DialogContent({ - seedThreadgate, - onChange, - onConfirm, -}: { - seedThreadgate: ThreadgateAllowUISetting[] - onChange?: (v: ThreadgateAllowUISetting[]) => void - onConfirm?: (v: ThreadgateAllowUISetting[]) => void -}) { + onChangeThreadgateUISettings, + onConfirmThreadgateUISettings, + threadgateUISettings, +}: Props) { const {_} = useLingui() const control = Dialog.useDialogContext() const {data: lists} = useMyListsQuery('curate') - const [draft, setDraft] = React.useState(seedThreadgate) + const [draft, setDraft] = React.useState(threadgateUISettings) - const [prevSeedThreadgate, setPrevSeedThreadgate] = - React.useState(seedThreadgate) - if (seedThreadgate !== prevSeedThreadgate) { + const [prevThreadgateUISettings, setPrevThreadgateUISettings] = + React.useState(threadgateUISettings) + if (threadgateUISettings !== prevThreadgateUISettings) { // New data flowed from above (e.g. due to update coming through). - setPrevSeedThreadgate(seedThreadgate) - setDraft(seedThreadgate) // Reset draft. + setPrevThreadgateUISettings(threadgateUISettings) + setDraft(threadgateUISettings) // Reset draft. } function updateThreadgate(nextThreadgate: ThreadgateAllowUISetting[]) { setDraft(nextThreadgate) - onChange?.(nextThreadgate) + onChangeThreadgateUISettings?.(nextThreadgate) } const onPressEverybody = () => { @@ -87,7 +84,7 @@ function DialogContent({ updateThreadgate(newSelected) } - const doneLabel = onConfirm ? _(msg`Save`) : _(msg`Done`) + const doneLabel = onConfirmThreadgateUISettings ? _(msg`Save`) : _(msg`Done`) return ( { control.close() - onConfirm?.(draft) + onConfirmThreadgateUISettings?.(draft) }} onAccessibilityEscape={control.close} color="primary" diff --git a/src/state/queries/postgate/index.ts b/src/state/queries/postgate/index.ts index d3b847675d..b487ab4dda 100644 --- a/src/state/queries/postgate/index.ts +++ b/src/state/queries/postgate/index.ts @@ -217,7 +217,6 @@ export function useToggleQuotepostEnabledMutation() { action: 'enable' | 'disable' }) => { await upsertPostgate({agent, postUri: postUri}, async prev => { - console.log({action}) if (prev) { if (action === 'disable') { return mergePostgateRecords(prev, { diff --git a/src/view/com/composer/threadgate/ThreadgateBtn.tsx b/src/view/com/composer/threadgate/ThreadgateBtn.tsx index 139393cd7c..2bf7f77014 100644 --- a/src/view/com/composer/threadgate/ThreadgateBtn.tsx +++ b/src/view/com/composer/threadgate/ThreadgateBtn.tsx @@ -67,8 +67,8 @@ export function ThreadgateBtn({ )