Fix types

This commit is contained in:
Paul Frazee
2024-02-13 11:21:25 -08:00
parent 95707a1511
commit 4e9eed5389
15 changed files with 84 additions and 205 deletions
@@ -49,22 +49,22 @@ export function Component({}: {}) {
<ContentLabelPref
preferences={preferences}
labelGroup="nsfw"
disabled={!preferences?.adultContentEnabled}
disabled={!preferences?.moderationOpts.adultContentEnabled}
/>
<ContentLabelPref
preferences={preferences}
labelGroup="nudity"
disabled={!preferences?.adultContentEnabled}
disabled={!preferences?.moderationOpts.adultContentEnabled}
/>
<ContentLabelPref
preferences={preferences}
labelGroup="suggestive"
disabled={!preferences?.adultContentEnabled}
disabled={!preferences?.moderationOpts.adultContentEnabled}
/>
<ContentLabelPref
preferences={preferences}
labelGroup="gore"
disabled={!preferences?.adultContentEnabled}
disabled={!preferences?.moderationOpts.adultContentEnabled}
/>
<ContentLabelPref preferences={preferences} labelGroup="hate" />
<ContentLabelPref preferences={preferences} labelGroup="spam" />
@@ -119,7 +119,9 @@ function AdultContentEnabledPref() {
try {
mutate({
enabled: !(variables?.enabled ?? preferences?.adultContentEnabled),
enabled: !(
variables?.enabled ?? preferences?.moderationOpts.adultContentEnabled
),
})
} catch (e) {
Toast.show(
@@ -136,7 +138,7 @@ function AdultContentEnabledPref() {
return (
<View style={s.mb10}>
{isIOS ? (
preferences?.adultContentEnabled ? null : (
preferences?.moderationOpts.adultContentEnabled ? null : (
<Text type="md" style={pal.textLight}>
<Trans>
Adult content can only be enabled via the Web at{' '}
@@ -165,7 +167,10 @@ function AdultContentEnabledPref() {
<ToggleButton
type="default-light"
label={_(msg`Enable Adult Content`)}
isSelected={variables?.enabled ?? preferences?.adultContentEnabled}
isSelected={
variables?.enabled ??
preferences?.moderationOpts.adultContentEnabled
}
onPress={onToggleAdultContent}
style={styles.toggleBtn}
/>
@@ -196,7 +201,7 @@ function ContentLabelPref({
disabled?: boolean
}) {
const pal = usePalette('default')
const visibility = preferences?.contentLabels?.[labelGroup]
const visibility = preferences?.moderationOpts.labelGroups?.[labelGroup]
const {mutate, variables} = usePreferencesSetContentLabelMutation()
const onChange = React.useCallback(
+7 -3
View File
@@ -34,7 +34,9 @@ export function AdultContentEnabledPref() {
try {
mutate({
enabled: !(variables?.enabled ?? preferences?.adultContentEnabled),
enabled: !(
variables?.enabled ?? preferences?.moderationOpts.adultContentEnabled
),
})
} catch (e) {
Toast.show(
@@ -47,7 +49,7 @@ export function AdultContentEnabledPref() {
return (
<View style={[pal.border, {borderTopWidth: 1, paddingHorizontal: 12}]}>
{isIOS ? (
preferences?.adultContentEnabled ? null : (
preferences?.moderationOpts.adultContentEnabled ? null : (
<View style={{paddingVertical: 12}}>
<Text type="md" style={pal.textLight}>
<Trans>
@@ -68,7 +70,9 @@ export function AdultContentEnabledPref() {
type="default-light"
label={_(msg`Enable Adult Content`)}
isSelected={
variables?.enabled ?? preferences?.adultContentEnabled ?? false
variables?.enabled ??
preferences?.moderationOpts.adultContentEnabled ??
false
}
onPress={onToggleAdultContent}
style={styles.toggleBtn}
+1 -1
View File
@@ -23,7 +23,7 @@ export function LabelGroupPref({
disabled?: boolean
}) {
const pal = usePalette('default')
const visibility = preferences?.contentLabels?.[labelGroup]
const visibility = preferences?.moderationOpts.labelGroups?.[labelGroup]
const {mutate, variables} = usePreferencesSetContentLabelMutation()
const onChange = React.useCallback(
+4 -4
View File
@@ -17,22 +17,22 @@ export function ModServicePrefs({}: {}) {
<LabelGroupPref
preferences={preferences}
labelGroup="nsfw"
disabled={!preferences?.adultContentEnabled}
disabled={!preferences?.moderationOpts.adultContentEnabled}
/>
<LabelGroupPref
preferences={preferences}
labelGroup="nudity"
disabled={!preferences?.adultContentEnabled}
disabled={!preferences?.moderationOpts.adultContentEnabled}
/>
<LabelGroupPref
preferences={preferences}
labelGroup="suggestive"
disabled={!preferences?.adultContentEnabled}
disabled={!preferences?.moderationOpts.adultContentEnabled}
/>
<LabelGroupPref
preferences={preferences}
labelGroup="gore"
disabled={!preferences?.adultContentEnabled}
disabled={!preferences?.moderationOpts.adultContentEnabled}
/>
<LabelGroupPref preferences={preferences} labelGroup="hate" />
<LabelGroupPref preferences={preferences} labelGroup="spam" />
+27 -28
View File
@@ -3,14 +3,12 @@ import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types'
import {View} from 'react-native'
import {
LABELS,
LABEL_GROUPS,
mock,
moderatePost,
moderateProfile,
PostModeration,
ProfileModeration,
ModerationUI,
LabelPreference,
AppBskyActorDefs,
AppBskyFeedDefs,
} from '@atproto/api'
@@ -39,12 +37,10 @@ const MOCK_MOD_OPTS = {
userDid: 'at://did:web:alice',
adultContentEnabled: true,
labelGroups: {},
labelers: [
mods: [
{
labeler: {did: 'did:plc:fake-labeler'},
labelGroups: Object.fromEntries(
Object.keys(LABEL_GROUPS).map(key => [key, 'hide' as LabelPreference]),
),
did: 'did:plc:fake-labeler',
enabled: true,
},
],
}
@@ -201,7 +197,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
<H3 style={a.pb_md}>
Account{' '}
<H3 style={[t.atoms.text_contrast_500, a.text_lg]}>in listing</H3>
<H3 style={[t.atoms.text_contrast_low, a.text_lg]}>in listing</H3>
</H3>
<MockAccountCard
label={label[0]}
@@ -225,16 +221,11 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
<H3 style={a.pb_md}>
Account{' '}
<H3 style={[t.atoms.text_contrast_500, a.text_lg]}>
<H3 style={[t.atoms.text_contrast_low, a.text_lg]}>
viewing directly
</H3>
</H3>
<MockAccountScreen
label={label[0]}
profile={profile}
moderation={profileModeration}
postModeration={postModeration}
/>
<MockAccountScreen label={label[0]} profile={profile} />
<View
style={[
t.atoms.bg_contrast_50,
@@ -267,7 +258,14 @@ function MockPost({
}) {
const t = useTheme()
return (
<View style={[t.atoms.border, a.border, a.rounded_md, a.mb_md, a.p_2xs]}>
<View
style={[
t.atoms.border_contrast_medium,
a.border,
a.rounded_md,
a.mb_md,
a.p_2xs,
]}>
{' '}
<PostHider
key={label}
@@ -285,7 +283,7 @@ function MockPost({
<View style={[a.flex_1]}>
<View style={[a.flex_row]}>
<P style={[a.font_bold]}>Bob Robertson </P>
<P style={t.atoms.text_contrast_500}>
<P style={t.atoms.text_contrast_low}>
@bob.bsky.social &middot; 5m
</P>
</View>
@@ -302,7 +300,7 @@ function MockPost({
moderationDecisions={moderation.decisions}>
<View
style={[
t.atoms.border,
t.atoms.border_contrast_medium,
a.border,
a.rounded_md,
a.flex_col,
@@ -312,7 +310,7 @@ function MockPost({
]}>
<View style={[a.flex_row]}>
<P style={[a.font_bold]}>Bob Robertson </P>
<P style={t.atoms.text_contrast_500}>
<P style={t.atoms.text_contrast_low}>
@bob.bsky.social &middot; 5m
</P>
</View>
@@ -341,7 +339,7 @@ function MockAccountCard({
<View
key={label}
style={[
t.atoms.border,
t.atoms.border_contrast_medium,
a.border,
a.rounded_md,
a.flex_row,
@@ -359,7 +357,7 @@ function MockAccountCard({
<P style={[a.font_bold]}>
{sanitizeDisplayName('Bob Robertson', moderation.profile)}{' '}
</P>
<P style={t.atoms.text_contrast_500}>@bob.bsky.social</P>
<P style={t.atoms.text_contrast_low}>@bob.bsky.social</P>
<P>Thought leader or something.</P>
<ProfileCardPills followedBy={false} moderation={moderation} />
</View>
@@ -370,19 +368,20 @@ function MockAccountCard({
function MockAccountScreen({
label,
profile,
moderation,
}: {
label: string
profile: AppBskyActorDefs.ProfileViewBasic
moderation: ProfileModeration
}) {
const t = useTheme()
return (
<View key={label} style={[t.atoms.border, a.border, a.mb_md]}>
<View
key={label}
style={[t.atoms.border_contrast_medium, a.border, a.mb_md]}>
<ProfileHeader
// @ts-ignore ProfileViewBasic is close enough -prf
profile={profile}
moderation={moderation}
moderationOpts={MOCK_MOD_OPTS}
descriptionRT={null /*TODO*/}
/>
{/*
@@ -400,12 +399,12 @@ function MockAccountScreen({
style={[
a.pb_2xl,
a.px_xl,
t.atoms.border,
t.atoms.border_contrast_medium,
a.border_b,
{paddingTop: 60},
]}>
<H3>Bob Robertson</H3>
<P style={t.atoms.text_contrast_500}>@bob.bsky.social</P>
<P style={t.atoms.text_contrast_low}>@bob.bsky.social</P>
<P>Thought leader or something.</P>
</View>
*/}
@@ -435,7 +434,7 @@ function Flag({v, label}: {v: boolean | undefined; label: string}) {
a.align_center,
a.rounded_xs,
a.border,
t.atoms.border,
t.atoms.border_contrast_medium,
{
backgroundColor: v ? t.palette.black : t.palette.white,
width: 14,