Handle global moderation label prefs with the global settings
This commit is contained in:
@@ -17,6 +17,7 @@ import {getLabelStrings} from '#/lib/moderation/useLabelInfo'
|
|||||||
|
|
||||||
import {useTheme, atoms as a} from '#/alf'
|
import {useTheme, atoms as a} from '#/alf'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
import {InlineLink} from '#/components/Link'
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Button, ButtonText, ButtonIcon} from '#/components/Button'
|
import {Button, ButtonText, ButtonIcon} from '#/components/Button'
|
||||||
import {ArrowTriangleBottom_Stroke2_Corner1_Rounded as ArrowTriangleBottom} from '../icons/ArrowTriangle'
|
import {ArrowTriangleBottom_Stroke2_Corner1_Rounded as ArrowTriangleBottom} from '../icons/ArrowTriangle'
|
||||||
@@ -36,10 +37,12 @@ export function ModerationLabelPref({
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const control = Dialog.useDialogControl()
|
const control = Dialog.useDialogControl()
|
||||||
|
|
||||||
|
const isGlobalLabel = !labelValueDefinition.definedBy
|
||||||
const {identifier} = labelValueDefinition
|
const {identifier} = labelValueDefinition
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
||||||
const savedPref = labelerDid
|
const savedPref =
|
||||||
|
labelerDid && !isGlobalLabel
|
||||||
? preferences?.moderationPrefs.labelers.find(l => l.did === labelerDid)
|
? preferences?.moderationPrefs.labelers.find(l => l.did === labelerDid)
|
||||||
?.labels[identifier]
|
?.labels[identifier]
|
||||||
: preferences?.moderationPrefs.labels[identifier]
|
: preferences?.moderationPrefs.labels[identifier]
|
||||||
@@ -74,8 +77,9 @@ export function ModerationLabelPref({
|
|||||||
labelValueDefinition.severity === 'none'
|
labelValueDefinition.severity === 'none'
|
||||||
)
|
)
|
||||||
const adultOnly = labelValueDefinition.flags.includes('adult')
|
const adultOnly = labelValueDefinition.flags.includes('adult')
|
||||||
const cantConfigure =
|
const adultDisabled =
|
||||||
adultOnly && !preferences?.moderationPrefs.adultContentEnabled
|
adultOnly && !preferences?.moderationPrefs.adultContentEnabled
|
||||||
|
const cantConfigure = isGlobalLabel || adultDisabled
|
||||||
|
|
||||||
const onSelectPref = (newPref: LabelPreference) =>
|
const onSelectPref = (newPref: LabelPreference) =>
|
||||||
mutate({label: identifier, visibility: newPref, labelerDid})
|
mutate({label: identifier, visibility: newPref, labelerDid})
|
||||||
@@ -144,9 +148,22 @@ export function ModerationLabelPref({
|
|||||||
<View style={[a.flex_row, a.gap_xs, a.align_center, a.pb_sm]}>
|
<View style={[a.flex_row, a.gap_xs, a.align_center, a.pb_sm]}>
|
||||||
<CircleInfo size="md" fill={t.atoms.text_contrast_medium.color} />
|
<CircleInfo size="md" fill={t.atoms.text_contrast_medium.color} />
|
||||||
<Text style={[a.text_md, t.atoms.text_contrast_medium]}>
|
<Text style={[a.text_md, t.atoms.text_contrast_medium]}>
|
||||||
|
{adultDisabled ? (
|
||||||
<Trans>
|
<Trans>
|
||||||
Adult content must be enabled to configure this label.
|
Adult content must be enabled to configure this label.
|
||||||
</Trans>
|
</Trans>
|
||||||
|
) : isGlobalLabel ? (
|
||||||
|
<Trans>
|
||||||
|
{labelStrings.name} is configured in your{' '}
|
||||||
|
<InlineLink
|
||||||
|
to="/moderation"
|
||||||
|
onPress={() => control.close()}
|
||||||
|
style={a.text_md}>
|
||||||
|
global moderation settings
|
||||||
|
</InlineLink>
|
||||||
|
.
|
||||||
|
</Trans>
|
||||||
|
) : null}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user