Extend post alerts to allow hidden replies
This commit is contained in:
@@ -13,6 +13,15 @@ import {
|
|||||||
} from '#/components/moderation/ModerationDetailsDialog'
|
} from '#/components/moderation/ModerationDetailsDialog'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
|
export type AppModerationCause =
|
||||||
|
| ModerationCause
|
||||||
|
| {
|
||||||
|
type: 'reply-hidden'
|
||||||
|
source: {type: 'user'}
|
||||||
|
priority: 6
|
||||||
|
downgraded?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
export type CommonProps = {
|
export type CommonProps = {
|
||||||
size?: 'sm' | 'lg'
|
size?: 'sm' | 'lg'
|
||||||
}
|
}
|
||||||
@@ -40,7 +49,7 @@ export function Row({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type LabelProps = {
|
export type LabelProps = {
|
||||||
cause: ModerationCause
|
cause: AppModerationCause
|
||||||
disableDetailsDialog?: boolean
|
disableDetailsDialog?: boolean
|
||||||
noBg?: boolean
|
noBg?: boolean
|
||||||
} & CommonProps
|
} & CommonProps
|
||||||
|
|||||||
@@ -12,13 +12,14 @@ import {atoms as a, useTheme} from '#/alf'
|
|||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {Divider} from '#/components/Divider'
|
import {Divider} from '#/components/Divider'
|
||||||
import {InlineLinkText} from '#/components/Link'
|
import {InlineLinkText} from '#/components/Link'
|
||||||
|
import {AppModerationCause} from '#/components/Pills'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
|
|
||||||
export {useDialogControl as useModerationDetailsDialogControl} from '#/components/Dialog'
|
export {useDialogControl as useModerationDetailsDialogControl} from '#/components/Dialog'
|
||||||
|
|
||||||
export interface ModerationDetailsDialogProps {
|
export interface ModerationDetailsDialogProps {
|
||||||
control: Dialog.DialogOuterProps['control']
|
control: Dialog.DialogOuterProps['control']
|
||||||
modcause: ModerationCause
|
modcause: ModerationCause | AppModerationCause
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ModerationDetailsDialog(props: ModerationDetailsDialogProps) {
|
export function ModerationDetailsDialog(props: ModerationDetailsDialogProps) {
|
||||||
@@ -105,6 +106,9 @@ function ModerationDetailsDialogInner({
|
|||||||
} else if (modcause.type === 'hidden') {
|
} else if (modcause.type === 'hidden') {
|
||||||
name = _(msg`Post Hidden by You`)
|
name = _(msg`Post Hidden by You`)
|
||||||
description = _(msg`You have hidden this post.`)
|
description = _(msg`You have hidden this post.`)
|
||||||
|
} else if (modcause.type === 'reply-hidden') {
|
||||||
|
name = _(msg`Post Hidden by Thread Author`)
|
||||||
|
description = _(msg`The author of this thread has hidden this post.`)
|
||||||
} else if (modcause.type === 'label') {
|
} else if (modcause.type === 'label') {
|
||||||
name = desc.name
|
name = desc.name
|
||||||
description = desc.description
|
description = desc.description
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {StyleProp, ViewStyle} from 'react-native'
|
import {StyleProp, ViewStyle} from 'react-native'
|
||||||
import {ModerationUI} from '@atproto/api'
|
import {ModerationCause, ModerationUI} from '@atproto/api'
|
||||||
|
|
||||||
import {getModerationCauseKey} from '#/lib/moderation'
|
import {getModerationCauseKey} from '#/lib/moderation'
|
||||||
import * as Pills from '#/components/Pills'
|
import * as Pills from '#/components/Pills'
|
||||||
@@ -9,13 +9,15 @@ export function PostAlerts({
|
|||||||
modui,
|
modui,
|
||||||
size = 'sm',
|
size = 'sm',
|
||||||
style,
|
style,
|
||||||
|
additionalCauses,
|
||||||
}: {
|
}: {
|
||||||
modui: ModerationUI
|
modui: ModerationUI
|
||||||
size?: Pills.CommonProps['size']
|
size?: Pills.CommonProps['size']
|
||||||
includeMute?: boolean
|
includeMute?: boolean
|
||||||
style?: StyleProp<ViewStyle>
|
style?: StyleProp<ViewStyle>
|
||||||
|
additionalCauses?: ModerationCause[] | Pills.AppModerationCause[]
|
||||||
}) {
|
}) {
|
||||||
if (!modui.alert && !modui.inform) {
|
if (!modui.alert && !modui.inform && !additionalCauses?.length) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +39,14 @@ export function PostAlerts({
|
|||||||
noBg={size === 'sm'}
|
noBg={size === 'sm'}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
{additionalCauses?.map(cause => (
|
||||||
|
<Pills.Label
|
||||||
|
key={getModerationCauseKey(cause)}
|
||||||
|
cause={cause}
|
||||||
|
size={size}
|
||||||
|
noBg={size === 'sm'}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
</Pills.Row>
|
</Pills.Row>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,20 @@
|
|||||||
import {
|
import {
|
||||||
ModerationCause,
|
|
||||||
ModerationUI,
|
|
||||||
InterpretedLabelValueDefinition,
|
|
||||||
LABELS,
|
|
||||||
AppBskyLabelerDefs,
|
AppBskyLabelerDefs,
|
||||||
BskyAgent,
|
BskyAgent,
|
||||||
|
InterpretedLabelValueDefinition,
|
||||||
|
LABELS,
|
||||||
|
ModerationCause,
|
||||||
ModerationOpts,
|
ModerationOpts,
|
||||||
|
ModerationUI,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
|
import {AppModerationCause} from '#/components/Pills'
|
||||||
|
|
||||||
export function getModerationCauseKey(cause: ModerationCause): string {
|
export function getModerationCauseKey(
|
||||||
|
cause: ModerationCause | AppModerationCause,
|
||||||
|
): string {
|
||||||
const source =
|
const source =
|
||||||
cause.source.type === 'labeler'
|
cause.source.type === 'labeler'
|
||||||
? cause.source.did
|
? cause.source.did
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/ico
|
|||||||
import {Props as SVGIconProps} from '#/components/icons/common'
|
import {Props as SVGIconProps} from '#/components/icons/common'
|
||||||
import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlash} from '#/components/icons/EyeSlash'
|
import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlash} from '#/components/icons/EyeSlash'
|
||||||
import {Warning_Stroke2_Corner0_Rounded as Warning} from '#/components/icons/Warning'
|
import {Warning_Stroke2_Corner0_Rounded as Warning} from '#/components/icons/Warning'
|
||||||
|
import {AppModerationCause} from '#/components/Pills'
|
||||||
import {useGlobalLabelStrings} from './useGlobalLabelStrings'
|
import {useGlobalLabelStrings} from './useGlobalLabelStrings'
|
||||||
import {getDefinition, getLabelStrings} from './useLabelInfo'
|
import {getDefinition, getLabelStrings} from './useLabelInfo'
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ export interface ModerationCauseDescription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useModerationCauseDescription(
|
export function useModerationCauseDescription(
|
||||||
cause: ModerationCause | undefined,
|
cause: ModerationCause | AppModerationCause | undefined,
|
||||||
): ModerationCauseDescription {
|
): ModerationCauseDescription {
|
||||||
const {_, i18n} = useLingui()
|
const {_, i18n} = useLingui()
|
||||||
const {labelDefs, labelers} = useLabelDefinitions()
|
const {labelDefs, labelers} = useLabelDefinitions()
|
||||||
@@ -111,6 +112,13 @@ export function useModerationCauseDescription(
|
|||||||
description: _(msg`You have hidden this post`),
|
description: _(msg`You have hidden this post`),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (cause.type === 'reply-hidden') {
|
||||||
|
return {
|
||||||
|
icon: EyeSlash,
|
||||||
|
name: _(msg`Post Hidden by Thread Author`),
|
||||||
|
description: _(msg`The author of this thread has hidden this post.`),
|
||||||
|
}
|
||||||
|
}
|
||||||
if (cause.type === 'label') {
|
if (cause.type === 'label') {
|
||||||
const def = cause.labelDef || getDefinition(labelDefs, cause.label)
|
const def = cause.labelDef || getDefinition(labelDefs, cause.label)
|
||||||
const strings = getLabelStrings(i18n.locale, globalLabelStrings, def)
|
const strings = getLabelStrings(i18n.locale, globalLabelStrings, def)
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {POST_TOMBSTONE, Shadow, usePostShadow} from '#/state/cache/post-shadow'
|
|||||||
import {useLanguagePrefs} from '#/state/preferences'
|
import {useLanguagePrefs} from '#/state/preferences'
|
||||||
import {useOpenLink} from '#/state/preferences/in-app-browser'
|
import {useOpenLink} from '#/state/preferences/in-app-browser'
|
||||||
import {ThreadPost} from '#/state/queries/post-thread'
|
import {ThreadPost} from '#/state/queries/post-thread'
|
||||||
|
import {useThreadgateRecordQuery} from '#/state/queries/threadgate'
|
||||||
import {useComposerControls} from '#/state/shell/composer'
|
import {useComposerControls} from '#/state/shell/composer'
|
||||||
import {MAX_POST_LINES} from 'lib/constants'
|
import {MAX_POST_LINES} from 'lib/constants'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
@@ -29,6 +30,7 @@ import {isWeb} from 'platform/detection'
|
|||||||
import {useSession} from 'state/session'
|
import {useSession} from 'state/session'
|
||||||
import {PostThreadFollowBtn} from 'view/com/post-thread/PostThreadFollowBtn'
|
import {PostThreadFollowBtn} from 'view/com/post-thread/PostThreadFollowBtn'
|
||||||
import {atoms as a} from '#/alf'
|
import {atoms as a} from '#/alf'
|
||||||
|
import {AppModerationCause} from '#/components/Pills'
|
||||||
import {RichText} from '#/components/RichText'
|
import {RichText} from '#/components/RichText'
|
||||||
import {ContentHider} from '../../../components/moderation/ContentHider'
|
import {ContentHider} from '../../../components/moderation/ContentHider'
|
||||||
import {LabelsOnMyPost} from '../../../components/moderation/LabelsOnMe'
|
import {LabelsOnMyPost} from '../../../components/moderation/LabelsOnMe'
|
||||||
@@ -199,6 +201,21 @@ let PostThreadItemLoaded = ({
|
|||||||
return makeProfileLink(post.author, 'post', urip.rkey, 'reposted-by')
|
return makeProfileLink(post.author, 'post', urip.rkey, 'reposted-by')
|
||||||
}, [post.uri, post.author])
|
}, [post.uri, post.author])
|
||||||
const repostsTitle = _(msg`Reposts of this post`)
|
const repostsTitle = _(msg`Reposts of this post`)
|
||||||
|
const {data: threadgateRecord} = useThreadgateRecordQuery({
|
||||||
|
postUri: rootUri,
|
||||||
|
})
|
||||||
|
const isPostHiddenByThreadgate = threadgateRecord?.hiddenReplies?.includes(
|
||||||
|
post.uri,
|
||||||
|
)
|
||||||
|
const additionalPostAlerts: AppModerationCause[] = isPostHiddenByThreadgate
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
type: 'reply-hidden',
|
||||||
|
source: {type: 'user'},
|
||||||
|
priority: 6,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []
|
||||||
|
|
||||||
const translatorUrl = getTranslatorLink(
|
const translatorUrl = getTranslatorLink(
|
||||||
record?.text || '',
|
record?.text || '',
|
||||||
@@ -315,6 +332,7 @@ let PostThreadItemLoaded = ({
|
|||||||
size="lg"
|
size="lg"
|
||||||
includeMute
|
includeMute
|
||||||
style={[a.pt_2xs, a.pb_sm]}
|
style={[a.pt_2xs, a.pb_sm]}
|
||||||
|
additionalCauses={additionalPostAlerts}
|
||||||
/>
|
/>
|
||||||
{richText?.text ? (
|
{richText?.text ? (
|
||||||
<View
|
<View
|
||||||
@@ -513,6 +531,7 @@ let PostThreadItemLoaded = ({
|
|||||||
<PostAlerts
|
<PostAlerts
|
||||||
modui={moderation.ui('contentList')}
|
modui={moderation.ui('contentList')}
|
||||||
style={[a.pt_2xs, a.pb_2xs]}
|
style={[a.pt_2xs, a.pb_2xs]}
|
||||||
|
additionalCauses={additionalPostAlerts}
|
||||||
/>
|
/>
|
||||||
{richText?.text ? (
|
{richText?.text ? (
|
||||||
<View style={styles.postTextContainer}>
|
<View style={styles.postTextContainer}>
|
||||||
|
|||||||
Reference in New Issue
Block a user