import React from 'react' import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types' import {View} from 'react-native' import { LABELS, mock, moderatePost, moderateProfile, PostModeration, ProfileModeration, ModerationUI, AppBskyActorDefs, AppBskyFeedDefs, } from '@atproto/api' import {atoms as a, useTheme} from '#/alf' import {CenteredView, ScrollView} from '#/view/com/util/Views' import {H1, H3, P} from '#/components/Typography' import {useLabelStrings} from '#/lib/moderation/useLabelStrings' import * as Toggle from '#/components/forms/Toggle' import * as ToggleButton from '#/components/forms/ToggleButton' import {UserAvatar} from '../com/util/UserAvatar' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {PostHider} from '../com/util/moderation/PostHider' import {PostAlerts} from '../com/util/moderation/PostAlerts' import {ContentHider} from '../com/util/moderation/ContentHider' import {ProfileHeader} from '../com/profile/ProfileHeader' import {sanitizeDisplayName} from '#/lib/strings/display-names' import {ProfileCardPills} from '../com/profile/ProfileCard' const LABEL_VALUES: (keyof typeof LABELS)[] = Object.keys( LABELS, ) as (keyof typeof LABELS)[] const MOCK_MOD_OPTS = { userDid: 'at://did:web:alice', adultContentEnabled: true, labelGroups: {}, mods: [ { did: 'did:plc:fake-labeler', enabled: true, }, ], } export const DebugModScreen = ({}: NativeStackScreenProps< CommonNavigatorParams, 'DebugMod' >) => { const t = useTheme() const [label, setLabel] = React.useState([LABEL_VALUES[0]]) const [target, setTarget] = React.useState(['account']) const labelStrings = useLabelStrings() const profile = React.useMemo(() => { const mockedProfile = mock.profileViewBasic({ handle: `bob.test`, displayName: 'Bob Robertson', labels: target[0] === 'account' ? [ mock.label({ val: label[0], uri: `at://did:web:bob/`, }), ] : target[0] === 'profile' ? [ mock.label({ val: label[0], uri: `at://did:web:bob/app.bsky.actor.profile/self`, }), ] : undefined, viewer: mock.actorViewerState({ muted: false, mutedByList: undefined, blockedBy: undefined, blocking: undefined, blockingByList: undefined, }), }) mockedProfile.avatar = 'https://bsky.social/about/images/favicon-32x32.png' mockedProfile.banner = 'https://bsky.social/about/images/social-card-default-gradient.png' return mockedProfile }, [target, label]) const post = React.useMemo(() => { return mock.postView({ record: mock.post({ text: "This is the body of the post. It's where the text goes. You get the idea.", }), author: profile, labels: target[0] === 'post' ? [ mock.label({ val: label[0], uri: `at://bob.test/app.bsky.feed.post/fake`, }), ] : undefined, embed: mock.embedRecordView({ record: mock.post({ text: 'Embed', }), labels: target[0] === 'embed' ? [ mock.label({ val: label[0], uri: `at://bob.test/app.bsky.feed.post/fake`, }), ] : undefined, author: profile, }), }) }, [label, target, profile]) const profileModeration = React.useMemo( () => moderateProfile(profile, MOCK_MOD_OPTS), [profile], ) const postModeration = React.useMemo( () => moderatePost(post, MOCK_MOD_OPTS), [post], ) console.log(post, profile) console.log(profileModeration, postModeration) return (

Moderation states

Target

Account Profile Post Embed

Label

{LABEL_VALUES.map(labelValue => ( {labelValue} ))}

Post

Account{' '}

in listing

Account{' '}

viewing directly

) } function MockPost({ label, post, moderation, }: { label: string post: AppBskyFeedDefs.PostView moderation: PostModeration }) { const t = useTheme() return ( {' '}

Bob Robertson

@bob.bsky.social · 5m

This is the body of the post. It's where the text goes. You get the idea.

Bob Robertson

@bob.bsky.social · 5m

Embedded content

) } function MockAccountCard({ label, profile, moderation, }: { label: string profile: AppBskyActorDefs.ProfileViewBasic moderation: ProfileModeration }) { const t = useTheme() return (

{sanitizeDisplayName('Bob Robertson', moderation.profile)}{' '}

@bob.bsky.social

Thought leader or something.

) } function MockAccountScreen({ label, profile, }: { label: string profile: AppBskyActorDefs.ProfileViewBasic }) { const t = useTheme() return ( {/*

Bob Robertson

@bob.bsky.social

Thought leader or something.

*/}
) } function ModerationUIView({mod, label}: {mod: ModerationUI; label: string}) { return (

{label}:

) } function Flag({v, label}: {v: boolean | undefined; label: string}) { const t = useTheme() return ( {v && }

{label}

) }