Disable mod prefs buttons, does not yet edit mod prefs
This commit is contained in:
@@ -1,8 +1,11 @@
|
|||||||
import React from 'react'
|
|
||||||
import {View} from 'react-native'
|
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 {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
import type React from 'react'
|
||||||
|
|
||||||
import {useGlobalLabelStrings} from '#/lib/moderation/useGlobalLabelStrings'
|
import {useGlobalLabelStrings} from '#/lib/moderation/useGlobalLabelStrings'
|
||||||
import {useLabelBehaviorDescription} from '#/lib/moderation/useLabelBehaviorDescription'
|
import {useLabelBehaviorDescription} from '#/lib/moderation/useLabelBehaviorDescription'
|
||||||
@@ -65,6 +68,7 @@ export function Buttons({
|
|||||||
ignoreLabel,
|
ignoreLabel,
|
||||||
warnLabel,
|
warnLabel,
|
||||||
hideLabel,
|
hideLabel,
|
||||||
|
disabled,
|
||||||
}: {
|
}: {
|
||||||
name: string
|
name: string
|
||||||
values: ToggleButton.GroupProps['values']
|
values: ToggleButton.GroupProps['values']
|
||||||
@@ -72,12 +76,14 @@ export function Buttons({
|
|||||||
ignoreLabel?: string
|
ignoreLabel?: string
|
||||||
warnLabel?: string
|
warnLabel?: string
|
||||||
hideLabel?: string
|
hideLabel?: string
|
||||||
|
disabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[{minHeight: 35}, a.w_full]}>
|
<View style={[{minHeight: 35}, a.w_full]}>
|
||||||
<ToggleButton.Group
|
<ToggleButton.Group
|
||||||
|
disabled={disabled}
|
||||||
label={_(
|
label={_(
|
||||||
msg`Configure content filtering setting for category: ${name}`,
|
msg`Configure content filtering setting for category: ${name}`,
|
||||||
)}
|
)}
|
||||||
@@ -143,22 +149,21 @@ export function GlobalLabelPreference({
|
|||||||
name={labelStrings.name}
|
name={labelStrings.name}
|
||||||
description={labelStrings.description}
|
description={labelStrings.description}
|
||||||
/>
|
/>
|
||||||
{!disabled && (
|
<Buttons
|
||||||
<Buttons
|
name={labelStrings.name.toLowerCase()}
|
||||||
name={labelStrings.name.toLowerCase()}
|
values={[pref]}
|
||||||
values={[pref]}
|
onChange={values => {
|
||||||
onChange={values => {
|
mutate({
|
||||||
mutate({
|
label: identifier,
|
||||||
label: identifier,
|
visibility: values[0] as LabelPreference,
|
||||||
visibility: values[0] as LabelPreference,
|
labelerDid: undefined,
|
||||||
labelerDid: undefined,
|
})
|
||||||
})
|
}}
|
||||||
}}
|
ignoreLabel={labelOptions.ignore}
|
||||||
ignoreLabel={labelOptions.ignore}
|
warnLabel={labelOptions.warn}
|
||||||
warnLabel={labelOptions.warn}
|
hideLabel={labelOptions.hide}
|
||||||
hideLabel={labelOptions.hide}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
</Outer>
|
</Outer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
} from '#/lib/routes/types'
|
} from '#/lib/routes/types'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {isIOS} from '#/platform/detection'
|
import {isIOS} from '#/platform/detection'
|
||||||
|
import {useAgeAssuranceContext} from '#/state/ageAssurance'
|
||||||
import {
|
import {
|
||||||
useMyLabelersQuery,
|
useMyLabelersQuery,
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
@@ -157,6 +158,7 @@ export function ModerationScreenInner({
|
|||||||
data: labelers,
|
data: labelers,
|
||||||
error: labelersError,
|
error: labelersError,
|
||||||
} = useMyLabelersQuery()
|
} = useMyLabelersQuery()
|
||||||
|
const {isAgeRestricted} = useAgeAssuranceContext()
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
@@ -352,7 +354,7 @@ export function ModerationScreenInner({
|
|||||||
</Text>
|
</Text>
|
||||||
<Toggle.Item
|
<Toggle.Item
|
||||||
label={_(msg`Toggle to enable or disable adult content`)}
|
label={_(msg`Toggle to enable or disable adult content`)}
|
||||||
disabled={disabledOnIOS}
|
disabled={disabledOnIOS || isAgeRestricted}
|
||||||
name="adultContent"
|
name="adultContent"
|
||||||
value={adultContentEnabled}
|
value={adultContentEnabled}
|
||||||
onChange={onToggleAdultContentEnabled}>
|
onChange={onToggleAdultContentEnabled}>
|
||||||
@@ -403,7 +405,10 @@ export function ModerationScreenInner({
|
|||||||
<Divider />
|
<Divider />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<GlobalLabelPreference labelDefinition={LABELS.nudity} />
|
<GlobalLabelPreference
|
||||||
|
disabled={isAgeRestricted}
|
||||||
|
labelDefinition={LABELS.nudity}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user