Handle reports on profile vs content
This commit is contained in:
@@ -33,7 +33,8 @@ import {useModServicesDetailedInfoQuery} from '#/state/queries/modservice'
|
|||||||
import {
|
import {
|
||||||
getLabelGroupsFromLabels,
|
getLabelGroupsFromLabels,
|
||||||
getModerationServiceTitle,
|
getModerationServiceTitle,
|
||||||
useConfigurableLabelGroups,
|
useConfigurableContentLabelGroups,
|
||||||
|
useConfigurableProfileLabelGroups,
|
||||||
} from '#/lib/moderation'
|
} from '#/lib/moderation'
|
||||||
import {DMCA_LINK} from '#/components/dialogs/ReportDialog/const'
|
import {DMCA_LINK} from '#/components/dialogs/ReportDialog/const'
|
||||||
import {Link} from '#/components/Link'
|
import {Link} from '#/components/Link'
|
||||||
@@ -42,12 +43,12 @@ import {SquareArrowTopRight_Stroke2_Corner0_Rounded as SquareArrowTopRight} from
|
|||||||
export type ReportDialogLabelIds = LabelGroupDefinition['id'] | 'other'
|
export type ReportDialogLabelIds = LabelGroupDefinition['id'] | 'other'
|
||||||
export type ReportDialogProps =
|
export type ReportDialogProps =
|
||||||
| {
|
| {
|
||||||
type: 'post'
|
type: 'content'
|
||||||
uri: string
|
uri: string
|
||||||
cid: string
|
cid: string
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'user'
|
type: 'profile'
|
||||||
did: string
|
did: string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,13 +385,15 @@ export function ReportDialog({
|
|||||||
ReportDialogLabelIds | undefined
|
ReportDialogLabelIds | undefined
|
||||||
>()
|
>()
|
||||||
const labelGroupStrings = useLabelGroupStrings()
|
const labelGroupStrings = useLabelGroupStrings()
|
||||||
const groups = useConfigurableLabelGroups()
|
const contentGroups = useConfigurableContentLabelGroups()
|
||||||
|
const profileGroups = useConfigurableProfileLabelGroups()
|
||||||
|
const groups = params.type === 'content' ? contentGroups : profileGroups
|
||||||
|
|
||||||
const i18n = React.useMemo(() => {
|
const i18n = React.useMemo(() => {
|
||||||
let title = _(msg`Report this post`)
|
let title = _(msg`Report this post`)
|
||||||
let description = _(msg`Why should this post be reviewed?`)
|
let description = _(msg`Why should this post be reviewed?`)
|
||||||
|
|
||||||
if (params.type === 'user') {
|
if (params.type === 'profile') {
|
||||||
title = _(msg`Report this user`)
|
title = _(msg`Report this user`)
|
||||||
description = _(msg`Why should this user be reviewed?`)
|
description = _(msg`Why should this user be reviewed?`)
|
||||||
}
|
}
|
||||||
@@ -474,6 +477,7 @@ export function ReportDialog({
|
|||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
{params.type === 'content' && (
|
||||||
<View style={[a.pt_md, a.px_md]}>
|
<View style={[a.pt_md, a.px_md]}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
@@ -502,6 +506,7 @@ export function ReportDialog({
|
|||||||
</Link>
|
</Link>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -39,6 +39,33 @@ export function useConfigurableLabelGroups() {
|
|||||||
return React.useMemo(() => getConfigurableLabelGroups(), [])
|
return React.useMemo(() => getConfigurableLabelGroups(), [])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useConfigurableContentLabelGroups() {
|
||||||
|
return React.useMemo(() => {
|
||||||
|
const groups = getConfigurableLabelGroups()
|
||||||
|
return groups.filter(group => {
|
||||||
|
return group.labels.every(l => l.targets.includes('content'))
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useConfigurableProfileLabelGroups() {
|
||||||
|
return React.useMemo(() => {
|
||||||
|
const groups = getConfigurableLabelGroups()
|
||||||
|
return groups.filter(group => {
|
||||||
|
return group.labels.every(l => l.targets.includes('profile'))
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useConfigurableAccountLabelGroups() {
|
||||||
|
return React.useMemo(() => {
|
||||||
|
const groups = getConfigurableLabelGroups()
|
||||||
|
return groups.filter(group => {
|
||||||
|
return group.labels.every(l => l.targets.includes('account'))
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
}
|
||||||
|
|
||||||
export function getModerationServiceTitle({
|
export function getModerationServiceTitle({
|
||||||
displayName,
|
displayName,
|
||||||
handle,
|
handle,
|
||||||
|
|||||||
@@ -58,6 +58,9 @@ import {LabelInfo} from '../util/moderation/LabelInfo'
|
|||||||
import {useProfileShadow} from 'state/cache/profile-shadow'
|
import {useProfileShadow} from 'state/cache/profile-shadow'
|
||||||
import * as ModerationServiceCard from '#/components/ModerationServiceCard'
|
import * as ModerationServiceCard from '#/components/ModerationServiceCard'
|
||||||
import {getModerationServiceTitle} from '#/lib/moderation'
|
import {getModerationServiceTitle} from '#/lib/moderation'
|
||||||
|
import {useOpenGlobalDialog} from '#/components/dialogs'
|
||||||
|
import {ReportDialog} from '#/components/dialogs/ReportDialog'
|
||||||
|
import {NEW_REPORT_DIALOG_ENABLED} from '#/lib/build-flags'
|
||||||
|
|
||||||
import {useTheme} from '#/alf'
|
import {useTheme} from '#/alf'
|
||||||
|
|
||||||
@@ -119,6 +122,7 @@ let ProfileHeader = ({
|
|||||||
() => moderateProfile(profile, moderationOpts),
|
() => moderateProfile(profile, moderationOpts),
|
||||||
[profile, moderationOpts],
|
[profile, moderationOpts],
|
||||||
)
|
)
|
||||||
|
const openDialog = useOpenGlobalDialog()
|
||||||
|
|
||||||
const invalidateProfileQuery = React.useCallback(() => {
|
const invalidateProfileQuery = React.useCallback(() => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
@@ -280,11 +284,15 @@ let ProfileHeader = ({
|
|||||||
|
|
||||||
const onPressReportAccount = React.useCallback(() => {
|
const onPressReportAccount = React.useCallback(() => {
|
||||||
track('ProfileHeader:ReportAccountButtonClicked')
|
track('ProfileHeader:ReportAccountButtonClicked')
|
||||||
|
if (NEW_REPORT_DIALOG_ENABLED) {
|
||||||
|
openDialog(ReportDialog, {type: 'profile', did: profile.did})
|
||||||
|
} else {
|
||||||
openModal({
|
openModal({
|
||||||
name: 'report',
|
name: 'report',
|
||||||
did: profile.did,
|
did: profile.did,
|
||||||
})
|
})
|
||||||
}, [track, openModal, profile])
|
}
|
||||||
|
}, [track, openModal, profile, openDialog])
|
||||||
|
|
||||||
const isMe = React.useMemo(
|
const isMe = React.useMemo(
|
||||||
() => currentAccount?.did === profile.did,
|
() => currentAccount?.did === profile.did,
|
||||||
|
|||||||
@@ -214,7 +214,11 @@ let PostDropdownBtn = ({
|
|||||||
label: _(msg`Report post`),
|
label: _(msg`Report post`),
|
||||||
onPress() {
|
onPress() {
|
||||||
if (NEW_REPORT_DIALOG_ENABLED) {
|
if (NEW_REPORT_DIALOG_ENABLED) {
|
||||||
openDialog(ReportDialog, {type: 'post', uri: postUri, cid: postCid})
|
openDialog(ReportDialog, {
|
||||||
|
type: 'content',
|
||||||
|
uri: postUri,
|
||||||
|
cid: postCid,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
openModal({
|
openModal({
|
||||||
name: 'report',
|
name: 'report',
|
||||||
|
|||||||
Reference in New Issue
Block a user