From 5f39ca31872af0554d79d9a6d0b070110385e9bd Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 21 Mar 2024 12:21:36 -0500 Subject: Mods UI fixes (#3296) * Fix report dialog buttons on Android by adjusting styles * Dry up label pref comp --- src/components/moderation/ModerationLabelPref.tsx | 177 ---------------------- 1 file changed, 177 deletions(-) delete mode 100644 src/components/moderation/ModerationLabelPref.tsx (limited to 'src/components/moderation/ModerationLabelPref.tsx') diff --git a/src/components/moderation/ModerationLabelPref.tsx b/src/components/moderation/ModerationLabelPref.tsx deleted file mode 100644 index b16c24859..000000000 --- a/src/components/moderation/ModerationLabelPref.tsx +++ /dev/null @@ -1,177 +0,0 @@ -import React from 'react' -import {View} from 'react-native' -import {InterpretedLabelValueDefinition, LabelPreference} from '@atproto/api' -import {useLingui} from '@lingui/react' -import {msg, Trans} from '@lingui/macro' - -import {useGlobalLabelStrings} from '#/lib/moderation/useGlobalLabelStrings' -import {useLabelBehaviorDescription} from '#/lib/moderation/useLabelBehaviorDescription' -import { - usePreferencesQuery, - usePreferencesSetContentLabelMutation, -} from '#/state/queries/preferences' -import {getLabelStrings} from '#/lib/moderation/useLabelInfo' - -import {useTheme, atoms as a, useBreakpoints} from '#/alf' -import {Text} from '#/components/Typography' -import {InlineLink} from '#/components/Link' -import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '../icons/CircleInfo' -import * as ToggleButton from '#/components/forms/ToggleButton' - -export function ModerationLabelPref({ - labelValueDefinition, - labelerDid, - disabled, -}: { - labelValueDefinition: InterpretedLabelValueDefinition - labelerDid: string | undefined - disabled?: boolean -}) { - const {_, i18n} = useLingui() - const t = useTheme() - const {gtPhone} = useBreakpoints() - - const isGlobalLabel = !labelValueDefinition.definedBy - const {identifier} = labelValueDefinition - const {data: preferences} = usePreferencesQuery() - const {mutate, variables} = usePreferencesSetContentLabelMutation() - const savedPref = - labelerDid && !isGlobalLabel - ? preferences?.moderationPrefs.labelers.find(l => l.did === labelerDid) - ?.labels[identifier] - : preferences?.moderationPrefs.labels[identifier] - const pref = - variables?.visibility ?? - savedPref ?? - labelValueDefinition.defaultSetting ?? - 'warn' - - // does the 'warn' setting make sense for this label? - const canWarn = !( - labelValueDefinition.blurs === 'none' && - labelValueDefinition.severity === 'none' - ) - // is this label adult only? - const adultOnly = labelValueDefinition.flags.includes('adult') - // is this label disabled because it's adult only? - const adultDisabled = - adultOnly && !preferences?.moderationPrefs.adultContentEnabled - // are there any reasons we cant configure this label here? - const cantConfigure = isGlobalLabel || adultDisabled - const showConfig = !disabled && (gtPhone || !cantConfigure) - - // adjust the pref based on whether warn is available - let prefAdjusted = pref - if (adultDisabled) { - prefAdjusted = 'hide' - } else if (!canWarn && pref === 'warn') { - prefAdjusted = 'ignore' - } - - // grab localized descriptions of the label and its settings - const currentPrefLabel = useLabelBehaviorDescription( - labelValueDefinition, - prefAdjusted, - ) - const hideLabel = useLabelBehaviorDescription(labelValueDefinition, 'hide') - const warnLabel = useLabelBehaviorDescription(labelValueDefinition, 'warn') - const ignoreLabel = useLabelBehaviorDescription( - labelValueDefinition, - 'ignore', - ) - const globalLabelStrings = useGlobalLabelStrings() - const labelStrings = getLabelStrings( - i18n.locale, - globalLabelStrings, - labelValueDefinition, - ) - - return ( - - - - {labelStrings.name} - - - {labelStrings.description} - - - {cantConfigure && ( - - - - - {adultDisabled ? ( - Adult content is disabled. - ) : isGlobalLabel ? ( - - Configured in{' '} - - moderation settings - - . - - ) : null} - - - )} - - - {showConfig && ( - - {cantConfigure ? ( - - - {currentPrefLabel} - - - ) : ( - - - mutate({ - label: identifier, - visibility: newPref[0] as LabelPreference, - labelerDid, - }) - }> - - {ignoreLabel} - - {canWarn && ( - - {warnLabel} - - )} - - {hideLabel} - - - - )} - - )} - - ) -} -- cgit 1.4.1