From 75b804fed91ec1cdaf4f27f6e544b0e6a03f4f8c Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 13 Aug 2024 15:16:01 -0500 Subject: [PATCH] Use toggle switch for QP setting --- .../dialogs/PostInteractionSettingsDialog.tsx | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/src/components/dialogs/PostInteractionSettingsDialog.tsx b/src/components/dialogs/PostInteractionSettingsDialog.tsx index fcd6d325ef..7b2727674c 100644 --- a/src/components/dialogs/PostInteractionSettingsDialog.tsx +++ b/src/components/dialogs/PostInteractionSettingsDialog.tsx @@ -38,6 +38,7 @@ import {atoms as a, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {Divider} from '#/components/Divider' +import * as Toggle from '#/components/forms/Toggle' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' import {Loader} from '#/components/Loader' @@ -242,6 +243,14 @@ export function PostInteractionSettingsForm({ const {_} = useLingui() const control = Dialog.useDialogContext() const {data: lists} = useMyListsQuery('curate') + const [quotesEnabled, setQuotesEnabled] = React.useState( + !( + postgate.embeddingRules && + postgate.embeddingRules.find( + v => v.$type === embeddingRules.disableRule.$type, + ) + ), + ) const onPressAudience = (setting: ThreadgateAllowUISetting) => { // remove boolean values @@ -260,16 +269,17 @@ export function PostInteractionSettingsForm({ onChangeThreadgateAllowUISettings(newSelected) } - const onChangeEmbeddingRules = React.useCallback( - (rules: AppBskyFeedPostgate.Record['embeddingRules']) => { + const onChangeQuotesEnabled = React.useCallback( + (enabled: boolean) => { + setQuotesEnabled(enabled) onChangePostgate( createPostgateRecord({ ...postgate, - embeddingRules: rules, + embeddingRules: enabled ? [] : [embeddingRules.disableRule], }), ) }, - [postgate, onChangePostgate], + [setQuotesEnabled, postgate, onChangePostgate], ) const noOneCanReply = !!threadgateAllowUISettings.find( @@ -285,7 +295,7 @@ export function PostInteractionSettingsForm({ - Customize who can engage with this post. + Customize who can interact with this post. @@ -295,34 +305,26 @@ export function PostInteractionSettingsForm({ Quote settings - - Allow quote posts from: - - - - onChangeEmbeddingRules([])} - style={{flex: 1}} - /> - v.$type === embeddingRules.disableRule.$type, - ), + + + {quotesEnabled ? ( + Quote posts enabled + ) : ( + Quote posts disabled )} - onPress={() => - onChangeEmbeddingRules([embeddingRules.disableRule]) - } - style={{flex: 1}} - /> - + + +