Fix types
This commit is contained in:
@@ -61,7 +61,7 @@ export function isCauseALabelOnUri(
|
|||||||
export function getModerationCauseKey(cause: ModerationCause): string {
|
export function getModerationCauseKey(cause: ModerationCause): string {
|
||||||
const source =
|
const source =
|
||||||
cause.source.type === 'labeler'
|
cause.source.type === 'labeler'
|
||||||
? cause.source.labeler.did
|
? cause.source.did
|
||||||
: cause.source.type === 'list'
|
: cause.source.type === 'list'
|
||||||
? cause.source.list.uri
|
? cause.source.list.uri
|
||||||
: 'user'
|
: 'user'
|
||||||
|
|||||||
@@ -56,7 +56,9 @@ export function AdultContentEnabledPref({
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mutate({
|
mutate({
|
||||||
enabled: !(variables?.enabled ?? preferences?.adultContentEnabled),
|
enabled: !(
|
||||||
|
variables?.enabled ?? preferences?.moderationOpts.adultContentEnabled
|
||||||
|
),
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
@@ -75,7 +77,10 @@ export function AdultContentEnabledPref({
|
|||||||
<Toggle.Item
|
<Toggle.Item
|
||||||
name={_(msg`Enable adult content in your feeds`)}
|
name={_(msg`Enable adult content in your feeds`)}
|
||||||
label={_(msg`Enable adult content in your feeds`)}
|
label={_(msg`Enable adult content in your feeds`)}
|
||||||
value={variables?.enabled ?? preferences?.adultContentEnabled}
|
value={
|
||||||
|
variables?.enabled ??
|
||||||
|
preferences?.moderationOpts.adultContentEnabled
|
||||||
|
}
|
||||||
onChange={onToggleAdultContent}>
|
onChange={onToggleAdultContent}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ export function ModerationOption({
|
|||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
||||||
const visibility =
|
const visibility =
|
||||||
variables?.visibility ?? preferences?.contentLabels?.[labelGroup]
|
variables?.visibility ??
|
||||||
|
preferences?.moderationOpts.labelGroups?.[labelGroup]
|
||||||
|
|
||||||
const onChange = React.useCallback(
|
const onChange = React.useCallback(
|
||||||
(vis: string[]) => {
|
(vis: string[]) => {
|
||||||
|
|||||||
@@ -6,17 +6,10 @@ import {logger} from '#/logger'
|
|||||||
import {getAgent} from '#/state/session'
|
import {getAgent} from '#/state/session'
|
||||||
import {useMyFollowsQuery} from '#/state/queries/my-follows'
|
import {useMyFollowsQuery} from '#/state/queries/my-follows'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {
|
import {DEFAULT_LOGGED_OUT_PREFERENCES, useModerationOpts} from './preferences'
|
||||||
DEFAULT_LOGGED_OUT_PREFERENCES,
|
|
||||||
getModerationOpts,
|
|
||||||
useModerationOpts,
|
|
||||||
} from './preferences'
|
|
||||||
import {isInvalidHandle} from '#/lib/strings/handles'
|
import {isInvalidHandle} from '#/lib/strings/handles'
|
||||||
|
|
||||||
const DEFAULT_MOD_OPTS = getModerationOpts({
|
const DEFAULT_MOD_OPTS = DEFAULT_LOGGED_OUT_PREFERENCES.moderationOpts
|
||||||
userDid: '',
|
|
||||||
preferences: DEFAULT_LOGGED_OUT_PREFERENCES,
|
|
||||||
})
|
|
||||||
|
|
||||||
export const RQKEY = (prefix: string) => ['actor-autocomplete', prefix]
|
export const RQKEY = (prefix: string) => ['actor-autocomplete', prefix]
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import {STALE} from '#/state/queries'
|
|||||||
import {precacheFeedPostProfiles} from './profile'
|
import {precacheFeedPostProfiles} from './profile'
|
||||||
import {getAgent} from '#/state/session'
|
import {getAgent} from '#/state/session'
|
||||||
import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const'
|
import {DEFAULT_LOGGED_OUT_PREFERENCES} from '#/state/queries/preferences/const'
|
||||||
import {getModerationOpts} from '#/state/queries/preferences/moderation'
|
|
||||||
import {KnownError} from '#/view/com/posts/FeedErrorMessage'
|
import {KnownError} from '#/view/com/posts/FeedErrorMessage'
|
||||||
import {embedViewRecordToPostView, getEmbeddedPost} from './util'
|
import {embedViewRecordToPostView, getEmbeddedPost} from './util'
|
||||||
import {useModerationOpts} from './preferences'
|
import {useModerationOpts} from './preferences'
|
||||||
@@ -429,11 +428,10 @@ function assertSomePostsPassModeration(feed: AppBskyFeedDefs.FeedViewPost[]) {
|
|||||||
let somePostsPassModeration = false
|
let somePostsPassModeration = false
|
||||||
|
|
||||||
for (const item of feed) {
|
for (const item of feed) {
|
||||||
const moderationOpts = getModerationOpts({
|
const moderation = moderatePost(
|
||||||
userDid: '',
|
item.post,
|
||||||
preferences: DEFAULT_LOGGED_OUT_PREFERENCES,
|
DEFAULT_LOGGED_OUT_PREFERENCES.moderationOpts,
|
||||||
})
|
)
|
||||||
const moderation = moderatePost(item.post, moderationOpts)
|
|
||||||
|
|
||||||
if (!moderation.content.filter) {
|
if (!moderation.content.filter) {
|
||||||
// we have a sfw post
|
// we have a sfw post
|
||||||
|
|||||||
@@ -29,21 +29,16 @@ export const DEFAULT_PROD_FEEDS = {
|
|||||||
|
|
||||||
export const DEFAULT_LOGGED_OUT_PREFERENCES: UsePreferencesQueryResponse = {
|
export const DEFAULT_LOGGED_OUT_PREFERENCES: UsePreferencesQueryResponse = {
|
||||||
birthDate: new Date('2022-11-17'), // TODO(pwi)
|
birthDate: new Date('2022-11-17'), // TODO(pwi)
|
||||||
adultContentEnabled: false,
|
|
||||||
feeds: {
|
feeds: {
|
||||||
saved: [],
|
saved: [],
|
||||||
pinned: [],
|
pinned: [],
|
||||||
unpinned: [],
|
unpinned: [],
|
||||||
},
|
},
|
||||||
// labels are undefined until set by user
|
moderationOpts: {
|
||||||
contentLabels: {
|
userDid: '',
|
||||||
nsfw: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES.nsfw,
|
adultContentEnabled: false,
|
||||||
nudity: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES.nudity,
|
labelGroups: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES,
|
||||||
suggestive: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES.suggestive,
|
mods: [],
|
||||||
gore: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES.gore,
|
|
||||||
hate: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES.hate,
|
|
||||||
spam: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES.spam,
|
|
||||||
impersonation: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES.impersonation,
|
|
||||||
},
|
},
|
||||||
feedViewPrefs: DEFAULT_HOME_FEED_PREFS,
|
feedViewPrefs: DEFAULT_HOME_FEED_PREFS,
|
||||||
threadViewPrefs: DEFAULT_THREAD_VIEW_PREFS,
|
threadViewPrefs: DEFAULT_THREAD_VIEW_PREFS,
|
||||||
|
|||||||
@@ -4,20 +4,17 @@ import {LabelPreference, BskyFeedViewPreference} from '@atproto/api'
|
|||||||
|
|
||||||
import {track} from '#/lib/analytics/analytics'
|
import {track} from '#/lib/analytics/analytics'
|
||||||
import {getAge} from '#/lib/strings/time'
|
import {getAge} from '#/lib/strings/time'
|
||||||
import {useSession, getAgent} from '#/state/session'
|
import {getAgent} from '#/state/session'
|
||||||
import {DEFAULT_LABEL_PREFERENCES} from '#/state/queries/preferences/moderation'
|
|
||||||
import {
|
import {
|
||||||
ConfigurableLabelGroup,
|
ConfigurableLabelGroup,
|
||||||
UsePreferencesQueryResponse,
|
UsePreferencesQueryResponse,
|
||||||
ThreadViewPreferences,
|
ThreadViewPreferences,
|
||||||
} from '#/state/queries/preferences/types'
|
} from '#/state/queries/preferences/types'
|
||||||
import {temp__migrateLabelPref} from '#/state/queries/preferences/util'
|
|
||||||
import {
|
import {
|
||||||
DEFAULT_HOME_FEED_PREFS,
|
DEFAULT_HOME_FEED_PREFS,
|
||||||
DEFAULT_THREAD_VIEW_PREFS,
|
DEFAULT_THREAD_VIEW_PREFS,
|
||||||
DEFAULT_LOGGED_OUT_PREFERENCES,
|
DEFAULT_LOGGED_OUT_PREFERENCES,
|
||||||
} from '#/state/queries/preferences/const'
|
} from '#/state/queries/preferences/const'
|
||||||
import {getModerationOpts} from '#/state/queries/preferences/moderation'
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {useHiddenPosts} from '#/state/preferences/hidden-posts'
|
import {useHiddenPosts} from '#/state/preferences/hidden-posts'
|
||||||
|
|
||||||
@@ -50,32 +47,6 @@ export function usePreferencesQuery() {
|
|||||||
return !res.feeds.pinned?.includes(f)
|
return !res.feeds.pinned?.includes(f)
|
||||||
}) || [],
|
}) || [],
|
||||||
},
|
},
|
||||||
// labels are undefined until set by user
|
|
||||||
contentLabels: {
|
|
||||||
nsfw: temp__migrateLabelPref(
|
|
||||||
res.contentLabels?.nsfw || DEFAULT_LABEL_PREFERENCES.nsfw,
|
|
||||||
),
|
|
||||||
nudity: temp__migrateLabelPref(
|
|
||||||
res.contentLabels?.nudity || DEFAULT_LABEL_PREFERENCES.nudity,
|
|
||||||
),
|
|
||||||
suggestive: temp__migrateLabelPref(
|
|
||||||
res.contentLabels?.suggestive ||
|
|
||||||
DEFAULT_LABEL_PREFERENCES.suggestive,
|
|
||||||
),
|
|
||||||
gore: temp__migrateLabelPref(
|
|
||||||
res.contentLabels?.gore || DEFAULT_LABEL_PREFERENCES.gore,
|
|
||||||
),
|
|
||||||
hate: temp__migrateLabelPref(
|
|
||||||
res.contentLabels?.hate || DEFAULT_LABEL_PREFERENCES.hate,
|
|
||||||
),
|
|
||||||
spam: temp__migrateLabelPref(
|
|
||||||
res.contentLabels?.spam || DEFAULT_LABEL_PREFERENCES.spam,
|
|
||||||
),
|
|
||||||
impersonation: temp__migrateLabelPref(
|
|
||||||
res.contentLabels?.impersonation ||
|
|
||||||
DEFAULT_LABEL_PREFERENCES.impersonation,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
feedViewPrefs: {
|
feedViewPrefs: {
|
||||||
...DEFAULT_HOME_FEED_PREFS,
|
...DEFAULT_HOME_FEED_PREFS,
|
||||||
...(res.feedViewPrefs.home || {}),
|
...(res.feedViewPrefs.home || {}),
|
||||||
@@ -93,23 +64,18 @@ export function usePreferencesQuery() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useModerationOpts() {
|
export function useModerationOpts() {
|
||||||
const {currentAccount} = useSession()
|
|
||||||
const prefs = usePreferencesQuery()
|
const prefs = usePreferencesQuery()
|
||||||
const hiddenPosts = useHiddenPosts()
|
const hiddenPosts = useHiddenPosts()
|
||||||
const opts = useMemo(() => {
|
const opts = useMemo(() => {
|
||||||
if (!prefs.data) {
|
if (!prefs.data) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const moderationOpts = getModerationOpts({
|
const moderationOpts = prefs.data.moderationOpts
|
||||||
userDid: currentAccount?.did || '',
|
|
||||||
preferences: prefs.data,
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...moderationOpts,
|
...moderationOpts,
|
||||||
hiddenPosts,
|
hiddenPosts,
|
||||||
}
|
}
|
||||||
}, [currentAccount?.did, prefs.data, hiddenPosts])
|
}, [prefs.data, hiddenPosts])
|
||||||
return opts
|
return opts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
import {
|
import {ComAtprotoLabelDefs, DEFAULT_LABEL_GROUP_SETTINGS} from '@atproto/api'
|
||||||
LabelPreference,
|
|
||||||
ComAtprotoLabelDefs,
|
|
||||||
ModerationOpts,
|
|
||||||
} from '@atproto/api'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
LabelGroup,
|
LabelGroup,
|
||||||
ConfigurableLabelGroup,
|
ConfigurableLabelGroup,
|
||||||
UsePreferencesQueryResponse,
|
|
||||||
} from '#/state/queries/preferences/types'
|
} from '#/state/queries/preferences/types'
|
||||||
|
|
||||||
export type Label = ComAtprotoLabelDefs.Label
|
export type Label = ComAtprotoLabelDefs.Label
|
||||||
@@ -21,36 +16,18 @@ export type LabelGroupConfig = {
|
|||||||
values: string[]
|
values: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_LABEL_PREFERENCES: Record<
|
|
||||||
ConfigurableLabelGroup,
|
|
||||||
LabelPreference
|
|
||||||
> = {
|
|
||||||
nsfw: 'hide',
|
|
||||||
nudity: 'warn',
|
|
||||||
suggestive: 'warn',
|
|
||||||
gore: 'warn',
|
|
||||||
hate: 'hide',
|
|
||||||
spam: 'hide',
|
|
||||||
impersonation: 'hide',
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More strict than our default settings for logged in users.
|
* More strict than our default settings for logged in users.
|
||||||
*
|
*
|
||||||
* TODO(pwi)
|
* TODO(pwi)
|
||||||
*/
|
*/
|
||||||
export const DEFAULT_LOGGED_OUT_LABEL_PREFERENCES: Record<
|
export const DEFAULT_LOGGED_OUT_LABEL_PREFERENCES: typeof DEFAULT_LABEL_GROUP_SETTINGS =
|
||||||
ConfigurableLabelGroup,
|
Object.fromEntries(
|
||||||
LabelPreference
|
Object.entries(DEFAULT_LABEL_GROUP_SETTINGS).map(([key, _pref]) => [
|
||||||
> = {
|
key,
|
||||||
nsfw: 'hide',
|
'hide',
|
||||||
nudity: 'hide',
|
]),
|
||||||
suggestive: 'hide',
|
)
|
||||||
gore: 'hide',
|
|
||||||
hate: 'hide',
|
|
||||||
spam: 'hide',
|
|
||||||
impersonation: 'hide',
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CONFIGURABLE_LABEL_GROUPS: Record<
|
export const CONFIGURABLE_LABEL_GROUPS: Record<
|
||||||
ConfigurableLabelGroup,
|
ConfigurableLabelGroup,
|
||||||
@@ -110,44 +87,3 @@ export const CONFIGURABLE_LABEL_GROUPS: Record<
|
|||||||
values: ['impersonation'],
|
values: ['impersonation'],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getModerationOpts({
|
|
||||||
userDid,
|
|
||||||
preferences,
|
|
||||||
}: {
|
|
||||||
userDid: string
|
|
||||||
preferences: UsePreferencesQueryResponse
|
|
||||||
}): ModerationOpts {
|
|
||||||
return {
|
|
||||||
userDid: userDid,
|
|
||||||
adultContentEnabled: preferences.adultContentEnabled,
|
|
||||||
labels: {
|
|
||||||
porn: preferences.contentLabels.nsfw,
|
|
||||||
sexual: preferences.contentLabels.suggestive,
|
|
||||||
nudity: preferences.contentLabels.nudity,
|
|
||||||
nsfl: preferences.contentLabels.gore,
|
|
||||||
corpse: preferences.contentLabels.gore,
|
|
||||||
gore: preferences.contentLabels.gore,
|
|
||||||
torture: preferences.contentLabels.gore,
|
|
||||||
'self-harm': preferences.contentLabels.gore,
|
|
||||||
'intolerant-race': preferences.contentLabels.hate,
|
|
||||||
'intolerant-gender': preferences.contentLabels.hate,
|
|
||||||
'intolerant-sexual-orientation': preferences.contentLabels.hate,
|
|
||||||
'intolerant-religion': preferences.contentLabels.hate,
|
|
||||||
intolerant: preferences.contentLabels.hate,
|
|
||||||
'icon-intolerant': preferences.contentLabels.hate,
|
|
||||||
spam: preferences.contentLabels.spam,
|
|
||||||
impersonation: preferences.contentLabels.impersonation,
|
|
||||||
scam: 'warn',
|
|
||||||
},
|
|
||||||
labelers: [
|
|
||||||
{
|
|
||||||
labeler: {
|
|
||||||
did: '',
|
|
||||||
displayName: 'Bluesky Social',
|
|
||||||
},
|
|
||||||
labels: {},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {
|
import {
|
||||||
BskyPreferences,
|
BskyPreferences,
|
||||||
LabelPreference,
|
|
||||||
BskyThreadViewPreference,
|
BskyThreadViewPreference,
|
||||||
BskyFeedViewPreference,
|
BskyFeedViewPreference,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
@@ -35,12 +34,6 @@ export type UsePreferencesQueryResponse = Omit<
|
|||||||
BskyPreferences,
|
BskyPreferences,
|
||||||
'contentLabels' | 'feedViewPrefs' | 'feeds'
|
'contentLabels' | 'feedViewPrefs' | 'feeds'
|
||||||
> & {
|
> & {
|
||||||
/*
|
|
||||||
* Content labels previously included 'show', which has been deprecated in
|
|
||||||
* favor of 'ignore'. The API can return legacy data from the database, and
|
|
||||||
* we clean up the data in `usePreferencesQuery`.
|
|
||||||
*/
|
|
||||||
contentLabels: Record<ConfigurableLabelGroup, LabelPreference>
|
|
||||||
feedViewPrefs: BskyFeedViewPreference & {
|
feedViewPrefs: BskyFeedViewPreference & {
|
||||||
lab_mergeFeedEnabled?: boolean
|
lab_mergeFeedEnabled?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
import {LabelPreference} from '@atproto/api'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Content labels previously included 'show', which has been deprecated in
|
|
||||||
* favor of 'ignore'. The API can return legacy data from the database, and
|
|
||||||
* we clean up the data in `usePreferencesQuery`.
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
export function temp__migrateLabelPref(
|
|
||||||
pref: LabelPreference | 'show',
|
|
||||||
): LabelPreference {
|
|
||||||
// @ts-ignore
|
|
||||||
if (pref === 'show') return 'ignore'
|
|
||||||
return pref
|
|
||||||
}
|
|
||||||
@@ -49,22 +49,22 @@ export function Component({}: {}) {
|
|||||||
<ContentLabelPref
|
<ContentLabelPref
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
labelGroup="nsfw"
|
labelGroup="nsfw"
|
||||||
disabled={!preferences?.adultContentEnabled}
|
disabled={!preferences?.moderationOpts.adultContentEnabled}
|
||||||
/>
|
/>
|
||||||
<ContentLabelPref
|
<ContentLabelPref
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
labelGroup="nudity"
|
labelGroup="nudity"
|
||||||
disabled={!preferences?.adultContentEnabled}
|
disabled={!preferences?.moderationOpts.adultContentEnabled}
|
||||||
/>
|
/>
|
||||||
<ContentLabelPref
|
<ContentLabelPref
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
labelGroup="suggestive"
|
labelGroup="suggestive"
|
||||||
disabled={!preferences?.adultContentEnabled}
|
disabled={!preferences?.moderationOpts.adultContentEnabled}
|
||||||
/>
|
/>
|
||||||
<ContentLabelPref
|
<ContentLabelPref
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
labelGroup="gore"
|
labelGroup="gore"
|
||||||
disabled={!preferences?.adultContentEnabled}
|
disabled={!preferences?.moderationOpts.adultContentEnabled}
|
||||||
/>
|
/>
|
||||||
<ContentLabelPref preferences={preferences} labelGroup="hate" />
|
<ContentLabelPref preferences={preferences} labelGroup="hate" />
|
||||||
<ContentLabelPref preferences={preferences} labelGroup="spam" />
|
<ContentLabelPref preferences={preferences} labelGroup="spam" />
|
||||||
@@ -119,7 +119,9 @@ function AdultContentEnabledPref() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mutate({
|
mutate({
|
||||||
enabled: !(variables?.enabled ?? preferences?.adultContentEnabled),
|
enabled: !(
|
||||||
|
variables?.enabled ?? preferences?.moderationOpts.adultContentEnabled
|
||||||
|
),
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
@@ -136,7 +138,7 @@ function AdultContentEnabledPref() {
|
|||||||
return (
|
return (
|
||||||
<View style={s.mb10}>
|
<View style={s.mb10}>
|
||||||
{isIOS ? (
|
{isIOS ? (
|
||||||
preferences?.adultContentEnabled ? null : (
|
preferences?.moderationOpts.adultContentEnabled ? null : (
|
||||||
<Text type="md" style={pal.textLight}>
|
<Text type="md" style={pal.textLight}>
|
||||||
<Trans>
|
<Trans>
|
||||||
Adult content can only be enabled via the Web at{' '}
|
Adult content can only be enabled via the Web at{' '}
|
||||||
@@ -165,7 +167,10 @@ function AdultContentEnabledPref() {
|
|||||||
<ToggleButton
|
<ToggleButton
|
||||||
type="default-light"
|
type="default-light"
|
||||||
label={_(msg`Enable Adult Content`)}
|
label={_(msg`Enable Adult Content`)}
|
||||||
isSelected={variables?.enabled ?? preferences?.adultContentEnabled}
|
isSelected={
|
||||||
|
variables?.enabled ??
|
||||||
|
preferences?.moderationOpts.adultContentEnabled
|
||||||
|
}
|
||||||
onPress={onToggleAdultContent}
|
onPress={onToggleAdultContent}
|
||||||
style={styles.toggleBtn}
|
style={styles.toggleBtn}
|
||||||
/>
|
/>
|
||||||
@@ -196,7 +201,7 @@ function ContentLabelPref({
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const visibility = preferences?.contentLabels?.[labelGroup]
|
const visibility = preferences?.moderationOpts.labelGroups?.[labelGroup]
|
||||||
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
||||||
|
|
||||||
const onChange = React.useCallback(
|
const onChange = React.useCallback(
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ export function AdultContentEnabledPref() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
mutate({
|
mutate({
|
||||||
enabled: !(variables?.enabled ?? preferences?.adultContentEnabled),
|
enabled: !(
|
||||||
|
variables?.enabled ?? preferences?.moderationOpts.adultContentEnabled
|
||||||
|
),
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Toast.show(
|
Toast.show(
|
||||||
@@ -47,7 +49,7 @@ export function AdultContentEnabledPref() {
|
|||||||
return (
|
return (
|
||||||
<View style={[pal.border, {borderTopWidth: 1, paddingHorizontal: 12}]}>
|
<View style={[pal.border, {borderTopWidth: 1, paddingHorizontal: 12}]}>
|
||||||
{isIOS ? (
|
{isIOS ? (
|
||||||
preferences?.adultContentEnabled ? null : (
|
preferences?.moderationOpts.adultContentEnabled ? null : (
|
||||||
<View style={{paddingVertical: 12}}>
|
<View style={{paddingVertical: 12}}>
|
||||||
<Text type="md" style={pal.textLight}>
|
<Text type="md" style={pal.textLight}>
|
||||||
<Trans>
|
<Trans>
|
||||||
@@ -68,7 +70,9 @@ export function AdultContentEnabledPref() {
|
|||||||
type="default-light"
|
type="default-light"
|
||||||
label={_(msg`Enable Adult Content`)}
|
label={_(msg`Enable Adult Content`)}
|
||||||
isSelected={
|
isSelected={
|
||||||
variables?.enabled ?? preferences?.adultContentEnabled ?? false
|
variables?.enabled ??
|
||||||
|
preferences?.moderationOpts.adultContentEnabled ??
|
||||||
|
false
|
||||||
}
|
}
|
||||||
onPress={onToggleAdultContent}
|
onPress={onToggleAdultContent}
|
||||||
style={styles.toggleBtn}
|
style={styles.toggleBtn}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ export function LabelGroupPref({
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const visibility = preferences?.contentLabels?.[labelGroup]
|
const visibility = preferences?.moderationOpts.labelGroups?.[labelGroup]
|
||||||
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
||||||
|
|
||||||
const onChange = React.useCallback(
|
const onChange = React.useCallback(
|
||||||
|
|||||||
@@ -17,22 +17,22 @@ export function ModServicePrefs({}: {}) {
|
|||||||
<LabelGroupPref
|
<LabelGroupPref
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
labelGroup="nsfw"
|
labelGroup="nsfw"
|
||||||
disabled={!preferences?.adultContentEnabled}
|
disabled={!preferences?.moderationOpts.adultContentEnabled}
|
||||||
/>
|
/>
|
||||||
<LabelGroupPref
|
<LabelGroupPref
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
labelGroup="nudity"
|
labelGroup="nudity"
|
||||||
disabled={!preferences?.adultContentEnabled}
|
disabled={!preferences?.moderationOpts.adultContentEnabled}
|
||||||
/>
|
/>
|
||||||
<LabelGroupPref
|
<LabelGroupPref
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
labelGroup="suggestive"
|
labelGroup="suggestive"
|
||||||
disabled={!preferences?.adultContentEnabled}
|
disabled={!preferences?.moderationOpts.adultContentEnabled}
|
||||||
/>
|
/>
|
||||||
<LabelGroupPref
|
<LabelGroupPref
|
||||||
preferences={preferences}
|
preferences={preferences}
|
||||||
labelGroup="gore"
|
labelGroup="gore"
|
||||||
disabled={!preferences?.adultContentEnabled}
|
disabled={!preferences?.moderationOpts.adultContentEnabled}
|
||||||
/>
|
/>
|
||||||
<LabelGroupPref preferences={preferences} labelGroup="hate" />
|
<LabelGroupPref preferences={preferences} labelGroup="hate" />
|
||||||
<LabelGroupPref preferences={preferences} labelGroup="spam" />
|
<LabelGroupPref preferences={preferences} labelGroup="spam" />
|
||||||
|
|||||||
@@ -3,14 +3,12 @@ import {NativeStackScreenProps, CommonNavigatorParams} from 'lib/routes/types'
|
|||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {
|
||||||
LABELS,
|
LABELS,
|
||||||
LABEL_GROUPS,
|
|
||||||
mock,
|
mock,
|
||||||
moderatePost,
|
moderatePost,
|
||||||
moderateProfile,
|
moderateProfile,
|
||||||
PostModeration,
|
PostModeration,
|
||||||
ProfileModeration,
|
ProfileModeration,
|
||||||
ModerationUI,
|
ModerationUI,
|
||||||
LabelPreference,
|
|
||||||
AppBskyActorDefs,
|
AppBskyActorDefs,
|
||||||
AppBskyFeedDefs,
|
AppBskyFeedDefs,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
@@ -39,12 +37,10 @@ const MOCK_MOD_OPTS = {
|
|||||||
userDid: 'at://did:web:alice',
|
userDid: 'at://did:web:alice',
|
||||||
adultContentEnabled: true,
|
adultContentEnabled: true,
|
||||||
labelGroups: {},
|
labelGroups: {},
|
||||||
labelers: [
|
mods: [
|
||||||
{
|
{
|
||||||
labeler: {did: 'did:plc:fake-labeler'},
|
did: 'did:plc:fake-labeler',
|
||||||
labelGroups: Object.fromEntries(
|
enabled: true,
|
||||||
Object.keys(LABEL_GROUPS).map(key => [key, 'hide' as LabelPreference]),
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
@@ -201,7 +197,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
|
|||||||
|
|
||||||
<H3 style={a.pb_md}>
|
<H3 style={a.pb_md}>
|
||||||
Account{' '}
|
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>
|
</H3>
|
||||||
<MockAccountCard
|
<MockAccountCard
|
||||||
label={label[0]}
|
label={label[0]}
|
||||||
@@ -225,16 +221,11 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
|
|||||||
|
|
||||||
<H3 style={a.pb_md}>
|
<H3 style={a.pb_md}>
|
||||||
Account{' '}
|
Account{' '}
|
||||||
<H3 style={[t.atoms.text_contrast_500, a.text_lg]}>
|
<H3 style={[t.atoms.text_contrast_low, a.text_lg]}>
|
||||||
viewing directly
|
viewing directly
|
||||||
</H3>
|
</H3>
|
||||||
</H3>
|
</H3>
|
||||||
<MockAccountScreen
|
<MockAccountScreen label={label[0]} profile={profile} />
|
||||||
label={label[0]}
|
|
||||||
profile={profile}
|
|
||||||
moderation={profileModeration}
|
|
||||||
postModeration={postModeration}
|
|
||||||
/>
|
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
t.atoms.bg_contrast_50,
|
t.atoms.bg_contrast_50,
|
||||||
@@ -267,7 +258,14 @@ function MockPost({
|
|||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
return (
|
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
|
<PostHider
|
||||||
key={label}
|
key={label}
|
||||||
@@ -285,7 +283,7 @@ function MockPost({
|
|||||||
<View style={[a.flex_1]}>
|
<View style={[a.flex_1]}>
|
||||||
<View style={[a.flex_row]}>
|
<View style={[a.flex_row]}>
|
||||||
<P style={[a.font_bold]}>Bob Robertson </P>
|
<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 · 5m
|
@bob.bsky.social · 5m
|
||||||
</P>
|
</P>
|
||||||
</View>
|
</View>
|
||||||
@@ -302,7 +300,7 @@ function MockPost({
|
|||||||
moderationDecisions={moderation.decisions}>
|
moderationDecisions={moderation.decisions}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
t.atoms.border,
|
t.atoms.border_contrast_medium,
|
||||||
a.border,
|
a.border,
|
||||||
a.rounded_md,
|
a.rounded_md,
|
||||||
a.flex_col,
|
a.flex_col,
|
||||||
@@ -312,7 +310,7 @@ function MockPost({
|
|||||||
]}>
|
]}>
|
||||||
<View style={[a.flex_row]}>
|
<View style={[a.flex_row]}>
|
||||||
<P style={[a.font_bold]}>Bob Robertson </P>
|
<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 · 5m
|
@bob.bsky.social · 5m
|
||||||
</P>
|
</P>
|
||||||
</View>
|
</View>
|
||||||
@@ -341,7 +339,7 @@ function MockAccountCard({
|
|||||||
<View
|
<View
|
||||||
key={label}
|
key={label}
|
||||||
style={[
|
style={[
|
||||||
t.atoms.border,
|
t.atoms.border_contrast_medium,
|
||||||
a.border,
|
a.border,
|
||||||
a.rounded_md,
|
a.rounded_md,
|
||||||
a.flex_row,
|
a.flex_row,
|
||||||
@@ -359,7 +357,7 @@ function MockAccountCard({
|
|||||||
<P style={[a.font_bold]}>
|
<P style={[a.font_bold]}>
|
||||||
{sanitizeDisplayName('Bob Robertson', moderation.profile)}{' '}
|
{sanitizeDisplayName('Bob Robertson', moderation.profile)}{' '}
|
||||||
</P>
|
</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>
|
<P>Thought leader or something.</P>
|
||||||
<ProfileCardPills followedBy={false} moderation={moderation} />
|
<ProfileCardPills followedBy={false} moderation={moderation} />
|
||||||
</View>
|
</View>
|
||||||
@@ -370,19 +368,20 @@ function MockAccountCard({
|
|||||||
function MockAccountScreen({
|
function MockAccountScreen({
|
||||||
label,
|
label,
|
||||||
profile,
|
profile,
|
||||||
moderation,
|
|
||||||
}: {
|
}: {
|
||||||
label: string
|
label: string
|
||||||
profile: AppBskyActorDefs.ProfileViewBasic
|
profile: AppBskyActorDefs.ProfileViewBasic
|
||||||
moderation: ProfileModeration
|
|
||||||
}) {
|
}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
return (
|
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
|
<ProfileHeader
|
||||||
// @ts-ignore ProfileViewBasic is close enough -prf
|
// @ts-ignore ProfileViewBasic is close enough -prf
|
||||||
profile={profile}
|
profile={profile}
|
||||||
moderation={moderation}
|
moderationOpts={MOCK_MOD_OPTS}
|
||||||
|
descriptionRT={null /*TODO*/}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/*
|
{/*
|
||||||
@@ -400,12 +399,12 @@ function MockAccountScreen({
|
|||||||
style={[
|
style={[
|
||||||
a.pb_2xl,
|
a.pb_2xl,
|
||||||
a.px_xl,
|
a.px_xl,
|
||||||
t.atoms.border,
|
t.atoms.border_contrast_medium,
|
||||||
a.border_b,
|
a.border_b,
|
||||||
{paddingTop: 60},
|
{paddingTop: 60},
|
||||||
]}>
|
]}>
|
||||||
<H3>Bob Robertson</H3>
|
<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>
|
<P>Thought leader or something.</P>
|
||||||
</View>
|
</View>
|
||||||
*/}
|
*/}
|
||||||
@@ -435,7 +434,7 @@ function Flag({v, label}: {v: boolean | undefined; label: string}) {
|
|||||||
a.align_center,
|
a.align_center,
|
||||||
a.rounded_xs,
|
a.rounded_xs,
|
||||||
a.border,
|
a.border,
|
||||||
t.atoms.border,
|
t.atoms.border_contrast_medium,
|
||||||
{
|
{
|
||||||
backgroundColor: v ? t.palette.black : t.palette.white,
|
backgroundColor: v ? t.palette.black : t.palette.white,
|
||||||
width: 14,
|
width: 14,
|
||||||
|
|||||||
Reference in New Issue
Block a user