Use toggle switch for QP setting
This commit is contained in:
@@ -38,6 +38,7 @@ import {atoms as a, useTheme} from '#/alf'
|
|||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Divider} from '#/components/Divider'
|
import {Divider} from '#/components/Divider'
|
||||||
|
import * as Toggle from '#/components/forms/Toggle'
|
||||||
import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check'
|
import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check'
|
||||||
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
|
import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
@@ -242,6 +243,14 @@ export function PostInteractionSettingsForm({
|
|||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const control = Dialog.useDialogContext()
|
const control = Dialog.useDialogContext()
|
||||||
const {data: lists} = useMyListsQuery('curate')
|
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) => {
|
const onPressAudience = (setting: ThreadgateAllowUISetting) => {
|
||||||
// remove boolean values
|
// remove boolean values
|
||||||
@@ -260,16 +269,17 @@ export function PostInteractionSettingsForm({
|
|||||||
onChangeThreadgateAllowUISettings(newSelected)
|
onChangeThreadgateAllowUISettings(newSelected)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onChangeEmbeddingRules = React.useCallback(
|
const onChangeQuotesEnabled = React.useCallback(
|
||||||
(rules: AppBskyFeedPostgate.Record['embeddingRules']) => {
|
(enabled: boolean) => {
|
||||||
|
setQuotesEnabled(enabled)
|
||||||
onChangePostgate(
|
onChangePostgate(
|
||||||
createPostgateRecord({
|
createPostgateRecord({
|
||||||
...postgate,
|
...postgate,
|
||||||
embeddingRules: rules,
|
embeddingRules: enabled ? [] : [embeddingRules.disableRule],
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
[postgate, onChangePostgate],
|
[setQuotesEnabled, postgate, onChangePostgate],
|
||||||
)
|
)
|
||||||
|
|
||||||
const noOneCanReply = !!threadgateAllowUISettings.find(
|
const noOneCanReply = !!threadgateAllowUISettings.find(
|
||||||
@@ -285,7 +295,7 @@ export function PostInteractionSettingsForm({
|
|||||||
|
|
||||||
<View style={[a.gap_lg]}>
|
<View style={[a.gap_lg]}>
|
||||||
<Text style={[a.text_md]}>
|
<Text style={[a.text_md]}>
|
||||||
<Trans>Customize who can engage with this post.</Trans>
|
<Trans>Customize who can interact with this post.</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
@@ -295,34 +305,26 @@ export function PostInteractionSettingsForm({
|
|||||||
<Trans>Quote settings</Trans>
|
<Trans>Quote settings</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
<Text style={[a.pt_sm, t.atoms.text_contrast_medium]}>
|
<Toggle.Item
|
||||||
<Trans>Allow quote posts from:</Trans>
|
name="quoteposts"
|
||||||
</Text>
|
type="checkbox"
|
||||||
|
label={
|
||||||
<View style={[a.flex_row, a.gap_sm]}>
|
quotesEnabled
|
||||||
<Selectable
|
? _(msg`Click to disable quote posts of this post.`)
|
||||||
label={_(msg`Everybody`)}
|
: _(msg`Click to enable quote posts of this post.`)
|
||||||
isSelected={
|
|
||||||
!postgate.embeddingRules ||
|
|
||||||
postgate.embeddingRules?.length === 0
|
|
||||||
}
|
}
|
||||||
onPress={() => onChangeEmbeddingRules([])}
|
value={quotesEnabled}
|
||||||
style={{flex: 1}}
|
onChange={onChangeQuotesEnabled}
|
||||||
/>
|
style={[, a.justify_between, a.pt_xs]}>
|
||||||
<Selectable
|
<Text style={[t.atoms.text_contrast_medium]}>
|
||||||
label={_(msg`Nobody`)}
|
{quotesEnabled ? (
|
||||||
isSelected={Boolean(
|
<Trans>Quote posts enabled</Trans>
|
||||||
postgate.embeddingRules &&
|
) : (
|
||||||
postgate.embeddingRules.find(
|
<Trans>Quote posts disabled</Trans>
|
||||||
v => v.$type === embeddingRules.disableRule.$type,
|
|
||||||
),
|
|
||||||
)}
|
)}
|
||||||
onPress={() =>
|
</Text>
|
||||||
onChangeEmbeddingRules([embeddingRules.disableRule])
|
<Toggle.Switch />
|
||||||
}
|
</Toggle.Item>
|
||||||
style={{flex: 1}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Divider />
|
<Divider />
|
||||||
|
|||||||
Reference in New Issue
Block a user