From cc635ae9495e2e9cbfa70ca9502848d941992899 Mon Sep 17 00:00:00 2001
From: Paul Frazee
Date: Tue, 13 Feb 2024 20:13:18 -0800
Subject: [PATCH] More work on the mod debug screen
---
src/lib/moderation/useLabelStrings.ts | 8 +-
src/view/com/util/moderation/ScreenHider.tsx | 2 +-
src/view/screens/DebugMod.tsx | 330 +++++++++++++------
3 files changed, 230 insertions(+), 110 deletions(-)
diff --git a/src/lib/moderation/useLabelStrings.ts b/src/lib/moderation/useLabelStrings.ts
index 4ca20e7dba..e6a376976f 100644
--- a/src/lib/moderation/useLabelStrings.ts
+++ b/src/lib/moderation/useLabelStrings.ts
@@ -672,21 +672,21 @@ export function useLabelStrings(): LabelStrings {
),
},
},
- curation: {
+ dislike: {
general: {
- name: _(msg`Curation`),
+ name: _(msg`Dislike`),
description: _(
msg`Judgment of the moderators to remove content they feel does not meet their standards of quality, however they choose to define it.`,
),
},
account: {
- name: _(msg`Curation`),
+ name: _(msg`Dislike`),
description: _(
msg`The moderators feel this account does not meet their standards of quality.`,
),
},
content: {
- name: _(msg`Curation`),
+ name: _(msg`Dislike`),
description: _(
msg`The moderators feel this content does not meet their standards of quality.`,
),
diff --git a/src/view/com/util/moderation/ScreenHider.tsx b/src/view/com/util/moderation/ScreenHider.tsx
index 56d9169acd..517db287aa 100644
--- a/src/view/com/util/moderation/ScreenHider.tsx
+++ b/src/view/com/util/moderation/ScreenHider.tsx
@@ -87,7 +87,7 @@ export function ScreenHider({
<>
This {screenDescription} has been flagged:
- {desc.name}.
+ {desc.name}.{' '}
{
diff --git a/src/view/screens/DebugMod.tsx b/src/view/screens/DebugMod.tsx
index c4ecddf761..55dd72d8c1 100644
--- a/src/view/screens/DebugMod.tsx
+++ b/src/view/screens/DebugMod.tsx
@@ -6,16 +6,19 @@ import {
mock,
moderatePost,
moderateProfile,
+ ModerationOpts,
PostModeration,
ProfileModeration,
ModerationUI,
AppBskyActorDefs,
AppBskyFeedDefs,
+ LabelTarget,
+ LabelPreference,
} 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 {H1, H3, P, Text} from '#/components/Typography'
import {useLabelStrings} from '#/lib/moderation/useLabelStrings'
import * as Toggle from '#/components/forms/Toggle'
import * as ToggleButton from '#/components/forms/ToggleButton'
@@ -25,6 +28,7 @@ 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 {ScreenHider} from '../com/util/moderation/ScreenHider'
import {ProfileHeader} from '../com/profile/ProfileHeader'
import {sanitizeDisplayName} from '#/lib/strings/display-names'
import {ProfileCardPills} from '../com/profile/ProfileCard'
@@ -52,6 +56,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
const t = useTheme()
const [label, setLabel] = React.useState([LABEL_VALUES[0]])
const [target, setTarget] = React.useState(['account'])
+ const [visibility, setVisiblity] = React.useState(['hide'])
const labelStrings = useLabelStrings()
const profile = React.useMemo(() => {
@@ -121,14 +126,22 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
})
}, [label, target, profile])
- const profileModeration = React.useMemo(
- () => moderateProfile(profile, MOCK_MOD_OPTS),
- [profile],
- )
- const postModeration = React.useMemo(
- () => moderatePost(post, MOCK_MOD_OPTS),
- [post],
- )
+ const modOpts = React.useMemo(() => {
+ return {
+ ...MOCK_MOD_OPTS,
+ labelGroups: {
+ [LABELS[label[0] as keyof typeof LABELS].groupId]:
+ visibility[0] as LabelPreference,
+ },
+ }
+ }, [label, visibility])
+
+ const profileModeration = React.useMemo(() => {
+ return moderateProfile(profile, modOpts)
+ }, [profile, modOpts])
+ const postModeration = React.useMemo(() => {
+ return moderatePost(post, modOpts)
+ }, [post, modOpts])
console.log(post, profile)
console.log(profileModeration, postModeration)
@@ -136,110 +149,178 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
return (
- Moderation states
+ Moderation states
- Target
-
-
-
- Account
-
-
- Profile
-
-
- Post
-
-
- Embed
-
-
-
+
+
+
+
+ Account
+
+
+ Profile
+
+
+ Post
+
+
+ Embed
+
+
- Label
+
+
+
+
+
+ Hide
+
+
+ Warn
+
+
+ Ignore
+
+
+
+
+
+
-
- {LABEL_VALUES.map(labelValue => (
-
-
- {labelValue}
-
- ))}
+
+ {LABEL_VALUES.map(labelValue => {
+ let targetFixed = target[0]
+ if (targetFixed !== 'account' && targetFixed !== 'profile') {
+ targetFixed = 'content'
+ }
+ const disabled = !LABELS[labelValue].targets.includes(
+ targetFixed as LabelTarget,
+ )
+ return (
+
+
+ {labelValue}
+
+ )
+ })}
- Post
-
+
+
+
+
+ {JSON.stringify(LABELS[label[0]], null, 2)}
+
+
+
+
+
+ Post moderation
+ Profile Moderation
+
+
+
+
+
-
- Account{' '}
- in listing
-
-
+
+
+
-
-
-
-
-
-
- Account{' '}
-
- viewing directly
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TODO
+
+
+
+ {(target[0] === 'account' || target[0] === 'profile') && (
+ <>
+
+ TODO
+
+
+
+
+
+
+
+
+
+
+ >
+ )}
@@ -247,25 +328,46 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
)
}
+function Heading({title, subtitle}: {title: string; subtitle?: string}) {
+ const t = useTheme()
+ return (
+
+ {title}{' '}
+ {!!subtitle && (
+ {subtitle}
+ )}
+
+ )
+}
+
+function Spacer() {
+ return
+}
+
function MockPost({
label,
+ context,
post,
moderation,
}: {
label: string
+ context: 'feed' | 'view' | 'reply'
post: AppBskyFeedDefs.PostView
moderation: PostModeration
}) {
const t = useTheme()
+
+ if (context === 'feed' && moderation.content.filter) {
+ return (
+
+ Filtered from the feed
+
+ )
+ }
+
return (
+ style={[t.atoms.border_contrast_medium, a.border, a.rounded_md, a.p_2xs]}>
{' '}
Bob Robertson
-
+
@bob.bsky.social · 5m
@@ -310,7 +412,7 @@ function MockPost({
]}>
Bob Robertson
-
+
@bob.bsky.social · 5m
@@ -335,6 +437,15 @@ function MockAccountCard({
moderation: ProfileModeration
}) {
const t = useTheme()
+
+ if (moderation.account.filter || moderation.profile.filter) {
+ return (
+
+ Filtered from the listing
+
+ )
+ }
+
return (
{sanitizeDisplayName('Bob Robertson', moderation.profile)}{' '}
- @bob.bsky.social
+ @bob.bsky.social
Thought leader or something.
@@ -368,23 +479,31 @@ function MockAccountCard({
function MockAccountScreen({
label,
profile,
+ moderation,
+ moderationOpts,
}: {
label: string
profile: AppBskyActorDefs.ProfileViewBasic
+ moderation: ProfileModeration
+ moderationOpts: ModerationOpts
}) {
const t = useTheme()
return (
-
+
+
- {/*
+ {/*
Bob Robertson
- @bob.bsky.social
+ @bob.bsky.social
Thought leader or something.
*/}
+
)
}