Disable mod prefs buttons, does not yet edit mod prefs

This commit is contained in:
Eric Bailey
2025-06-26 10:55:51 -05:00
parent fa662dec9c
commit 1c77aedb5a
2 changed files with 30 additions and 20 deletions
+23 -18
View File
@@ -1,8 +1,11 @@
import React from 'react'
import {View} from 'react-native'
import {InterpretedLabelValueDefinition, LabelPreference} from '@atproto/api'
import {
type InterpretedLabelValueDefinition,
type LabelPreference,
} from '@atproto/api'
import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import type React from 'react'
import {useGlobalLabelStrings} from '#/lib/moderation/useGlobalLabelStrings'
import {useLabelBehaviorDescription} from '#/lib/moderation/useLabelBehaviorDescription'
@@ -65,6 +68,7 @@ export function Buttons({
ignoreLabel,
warnLabel,
hideLabel,
disabled,
}: {
name: string
values: ToggleButton.GroupProps['values']
@@ -72,12 +76,14 @@ export function Buttons({
ignoreLabel?: string
warnLabel?: string
hideLabel?: string
disabled?: boolean
}) {
const {_} = useLingui()
return (
<View style={[{minHeight: 35}, a.w_full]}>
<ToggleButton.Group
disabled={disabled}
label={_(
msg`Configure content filtering setting for category: ${name}`,
)}
@@ -143,22 +149,21 @@ export function GlobalLabelPreference({
name={labelStrings.name}
description={labelStrings.description}
/>
{!disabled && (
<Buttons
name={labelStrings.name.toLowerCase()}
values={[pref]}
onChange={values => {
mutate({
label: identifier,
visibility: values[0] as LabelPreference,
labelerDid: undefined,
})
}}
ignoreLabel={labelOptions.ignore}
warnLabel={labelOptions.warn}
hideLabel={labelOptions.hide}
/>
)}
<Buttons
name={labelStrings.name.toLowerCase()}
values={[pref]}
onChange={values => {
mutate({
label: identifier,
visibility: values[0] as LabelPreference,
labelerDid: undefined,
})
}}
ignoreLabel={labelOptions.ignore}
warnLabel={labelOptions.warn}
hideLabel={labelOptions.hide}
disabled={disabled}
/>
</Outer>
)
}
+7 -2
View File
@@ -12,6 +12,7 @@ import {
} from '#/lib/routes/types'
import {logger} from '#/logger'
import {isIOS} from '#/platform/detection'
import {useAgeAssuranceContext} from '#/state/ageAssurance'
import {
useMyLabelersQuery,
usePreferencesQuery,
@@ -157,6 +158,7 @@ export function ModerationScreenInner({
data: labelers,
error: labelersError,
} = useMyLabelersQuery()
const {isAgeRestricted} = useAgeAssuranceContext()
useFocusEffect(
useCallback(() => {
@@ -352,7 +354,7 @@ export function ModerationScreenInner({
</Text>
<Toggle.Item
label={_(msg`Toggle to enable or disable adult content`)}
disabled={disabledOnIOS}
disabled={disabledOnIOS || isAgeRestricted}
name="adultContent"
value={adultContentEnabled}
onChange={onToggleAdultContentEnabled}>
@@ -403,7 +405,10 @@ export function ModerationScreenInner({
<Divider />
</>
)}
<GlobalLabelPreference labelDefinition={LABELS.nudity} />
<GlobalLabelPreference
disabled={isAgeRestricted}
labelDefinition={LABELS.nudity}
/>
</View>
</View>