Update profile to pull from labeler definition

This commit is contained in:
Paul Frazee
2024-03-04 14:02:54 -08:00
parent 473ca0deff
commit 4d0dc7438b
6 changed files with 138 additions and 80 deletions
+17 -11
View File
@@ -2,6 +2,7 @@ import React from 'react'
import {View} from 'react-native'
import {useLingui} from '@lingui/react'
import {msg} from '@lingui/macro'
import {InterprettedLabelValueDefinition} from '@atproto/api'
import {useLabelStrings} from '#/lib/moderation/useLabelStrings'
@@ -10,21 +11,26 @@ import {Text} from '#/components/Typography'
import * as ToggleButton from '#/components/forms/ToggleButton'
export function ModerationLabelPref({
label,
labelValueDefinition,
disabled,
}: {
label: string
labelValueDefinition: InterprettedLabelValueDefinition
disabled?: boolean
}) {
console.log({labelValueDefinition})
const t = useTheme()
const {_} = useLingui()
const allLabelStrings = useLabelStrings()
const labelStrings = allLabelStrings[label] || {
general: {
name: label,
description: `Labeled "${label}"`,
},
}
const labelStrings = labelValueDefinition.locales[0] // TODO look up locale
? labelValueDefinition.locales[0]
: labelValueDefinition.identifier in allLabelStrings
? allLabelStrings[labelValueDefinition.identifier].general
: {
general: {
name: labelValueDefinition.identifier,
description: `Labeled "${labelValueDefinition.identifier}"`,
},
}
// TODO add onChange behavior when mod prefs are updated
@@ -46,16 +52,16 @@ export function ModerationLabelPref({
a.align_center,
]}>
<View style={[a.gap_xs, {width: '50%'}]}>
<Text style={[a.font_bold]}>{labelStrings.general.name}</Text>
<Text style={[a.font_bold]}>{labelStrings.name}</Text>
<Text style={[t.atoms.text_contrast_medium, a.leading_snug]}>
{labelStrings.general.description}
{labelStrings.description}
</Text>
</View>
<View style={[a.justify_center, {minHeight: 35}]}>
{!disabled && (
<ToggleButton.Group
label={_(
msg`Configure content filtering setting for category: ${labelStrings.general.name.toLowerCase()}`,
msg`Configure content filtering setting for category: ${labelStrings.name.toLowerCase()}`,
)}
values={['hide']}
onChange={() => {}}>