Skip labeler selection for Bluesky-only cases
This commit is contained in:
@@ -113,6 +113,13 @@ function Inner(props: ReportDialogProps) {
|
|||||||
const [isPending, setPending] = React.useState(false)
|
const [isPending, setPending] = React.useState(false)
|
||||||
const [isSuccess, setSuccess] = React.useState(false)
|
const [isSuccess, setSuccess] = React.useState(false)
|
||||||
|
|
||||||
|
// some reasons ONLY go to Bluesky
|
||||||
|
const isBskyOnlyReason = state?.selectedOption?.reason
|
||||||
|
? BSKY_LABELER_ONLY_REPORT_REASONS.has(state.selectedOption.reason)
|
||||||
|
: false
|
||||||
|
// some subjects (chats) only go to Bluesky
|
||||||
|
const isBskyOnlySubject = props.subject.type === 'convoMessage'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Labelers that support this `subject` and its NSID collection
|
* Labelers that support this `subject` and its NSID collection
|
||||||
*/
|
*/
|
||||||
@@ -139,12 +146,6 @@ function Inner(props: ReportDialogProps) {
|
|||||||
})
|
})
|
||||||
.filter(l => {
|
.filter(l => {
|
||||||
if (!state.selectedOption) return false
|
if (!state.selectedOption) return false
|
||||||
// some reasons ONLY go to Bluesky
|
|
||||||
const isBskyOnlyReason = BSKY_LABELER_ONLY_REPORT_REASONS.has(
|
|
||||||
state.selectedOption.reason,
|
|
||||||
)
|
|
||||||
// some subjects (chats) only go to Bluesky
|
|
||||||
const isBskyOnlySubject = props.subject.type === 'convoMessage'
|
|
||||||
if (isBskyOnlyReason || isBskyOnlySubject) {
|
if (isBskyOnlyReason || isBskyOnlySubject) {
|
||||||
return l.creator.did === BSKY_LABELER_DID
|
return l.creator.did === BSKY_LABELER_DID
|
||||||
}
|
}
|
||||||
@@ -159,10 +160,25 @@ function Inner(props: ReportDialogProps) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}, [props, allLabelers, state.selectedOption])
|
}, [
|
||||||
|
props,
|
||||||
|
allLabelers,
|
||||||
|
state.selectedOption,
|
||||||
|
isBskyOnlyReason,
|
||||||
|
isBskyOnlySubject,
|
||||||
|
])
|
||||||
const hasSupportedLabelers = !!supportedLabelers.length
|
const hasSupportedLabelers = !!supportedLabelers.length
|
||||||
const hasSingleSupportedLabeler = supportedLabelers.length === 1
|
const hasSingleSupportedLabeler = supportedLabelers.length === 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We skip the select labeler step if there's only one possible labeler, and
|
||||||
|
* that labeler is Bluesky (which is the case for chat reports and certain
|
||||||
|
* reason types). We'll use this below to adjust the indexing and skip the
|
||||||
|
* step in the UI.
|
||||||
|
*/
|
||||||
|
const isAlwaysBskyLabeler =
|
||||||
|
hasSingleSupportedLabeler && (isBskyOnlyReason || isBskyOnlySubject)
|
||||||
|
|
||||||
const onSubmit = React.useCallback(async () => {
|
const onSubmit = React.useCallback(async () => {
|
||||||
dispatch({type: 'clearError'})
|
dispatch({type: 'clearError'})
|
||||||
|
|
||||||
@@ -376,88 +392,104 @@ function Inner(props: ReportDialogProps) {
|
|||||||
) : null}
|
) : null}
|
||||||
</StepOuter>
|
</StepOuter>
|
||||||
|
|
||||||
<StepOuter>
|
{isAlwaysBskyLabeler ? (
|
||||||
<StepTitle
|
<ActionOnce
|
||||||
index={3}
|
check={() => !state.selectedLabeler}
|
||||||
title={_(msg`Select moderation service`)}
|
callback={() => {
|
||||||
activeIndex1={state.activeStepIndex1}
|
dispatch({
|
||||||
|
type: 'selectLabeler',
|
||||||
|
labeler: supportedLabelers[0],
|
||||||
|
})
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{state.activeStepIndex1 >= 3 && (
|
) : (
|
||||||
<>
|
<StepOuter>
|
||||||
{state.selectedLabeler ? (
|
<StepTitle
|
||||||
<>
|
index={3}
|
||||||
{hasSingleSupportedLabeler ? (
|
title={_(msg`Select moderation service`)}
|
||||||
<LabelerCard labeler={state.selectedLabeler} />
|
activeIndex1={state.activeStepIndex1}
|
||||||
) : (
|
/>
|
||||||
<View style={[a.flex_row, a.align_center, a.gap_md]}>
|
{state.activeStepIndex1 >= 3 && (
|
||||||
<View style={[a.flex_1]}>
|
<>
|
||||||
<LabelerCard labeler={state.selectedLabeler} />
|
{state.selectedLabeler ? (
|
||||||
|
<>
|
||||||
|
{hasSingleSupportedLabeler ? (
|
||||||
|
<LabelerCard labeler={state.selectedLabeler} />
|
||||||
|
) : (
|
||||||
|
<View style={[a.flex_row, a.align_center, a.gap_md]}>
|
||||||
|
<View style={[a.flex_1]}>
|
||||||
|
<LabelerCard labeler={state.selectedLabeler} />
|
||||||
|
</View>
|
||||||
|
<Button
|
||||||
|
label={_(msg`Change moderation service`)}
|
||||||
|
size="tiny"
|
||||||
|
variant="solid"
|
||||||
|
color="secondary"
|
||||||
|
shape="round"
|
||||||
|
onPress={() => {
|
||||||
|
dispatch({type: 'clearLabeler'})
|
||||||
|
}}>
|
||||||
|
<ButtonIcon icon={X} />
|
||||||
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
<Button
|
)}
|
||||||
label={_(msg`Change moderation service`)}
|
</>
|
||||||
size="tiny"
|
) : (
|
||||||
variant="solid"
|
<>
|
||||||
color="secondary"
|
{hasSupportedLabelers ? (
|
||||||
shape="round"
|
<View style={[a.gap_sm]}>
|
||||||
onPress={() => {
|
{hasSingleSupportedLabeler ? (
|
||||||
dispatch({type: 'clearLabeler'})
|
<>
|
||||||
}}>
|
<LabelerCard labeler={supportedLabelers[0]} />
|
||||||
<ButtonIcon icon={X} />
|
<ActionOnce
|
||||||
</Button>
|
check={() => !state.selectedLabeler}
|
||||||
</View>
|
callback={() => {
|
||||||
)}
|
dispatch({
|
||||||
</>
|
type: 'selectLabeler',
|
||||||
) : (
|
labeler: supportedLabelers[0],
|
||||||
<>
|
})
|
||||||
{hasSupportedLabelers ? (
|
|
||||||
<View style={[a.gap_sm]}>
|
|
||||||
{hasSingleSupportedLabeler ? (
|
|
||||||
<>
|
|
||||||
<LabelerCard labeler={supportedLabelers[0]} />
|
|
||||||
<ActionOnce
|
|
||||||
check={() => !state.selectedLabeler}
|
|
||||||
callback={() => {
|
|
||||||
dispatch({
|
|
||||||
type: 'selectLabeler',
|
|
||||||
labeler: supportedLabelers[0],
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
{supportedLabelers.map(l => (
|
|
||||||
<LabelerCard
|
|
||||||
key={l.creator.did}
|
|
||||||
labeler={l}
|
|
||||||
onSelect={() => {
|
|
||||||
dispatch({type: 'selectLabeler', labeler: l})
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
</>
|
||||||
</>
|
) : (
|
||||||
)}
|
<>
|
||||||
</View>
|
{supportedLabelers.map(l => (
|
||||||
) : (
|
<LabelerCard
|
||||||
// should never happen in our app
|
key={l.creator.did}
|
||||||
<Admonition.Admonition type="warning">
|
labeler={l}
|
||||||
<Trans>
|
onSelect={() => {
|
||||||
Unfortunately, none of your subscribed labelers supports
|
dispatch({type: 'selectLabeler', labeler: l})
|
||||||
this report type.
|
}}
|
||||||
</Trans>
|
/>
|
||||||
</Admonition.Admonition>
|
))}
|
||||||
)}
|
</>
|
||||||
</>
|
)}
|
||||||
)}
|
</View>
|
||||||
</>
|
) : (
|
||||||
)}
|
// should never happen in our app
|
||||||
</StepOuter>
|
<Admonition.Admonition type="warning">
|
||||||
|
<Trans>
|
||||||
|
Unfortunately, none of your subscribed labelers
|
||||||
|
supports this report type.
|
||||||
|
</Trans>
|
||||||
|
</Admonition.Admonition>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</StepOuter>
|
||||||
|
)}
|
||||||
|
|
||||||
<StepOuter>
|
<StepOuter>
|
||||||
<StepTitle
|
<StepTitle
|
||||||
index={4}
|
index={isAlwaysBskyLabeler ? 3 : 4}
|
||||||
title={_(msg`Submit report`)}
|
title={_(msg`Submit report`)}
|
||||||
activeIndex1={state.activeStepIndex1}
|
activeIndex1={
|
||||||
|
isAlwaysBskyLabeler
|
||||||
|
? state.activeStepIndex1 - 1
|
||||||
|
: state.activeStepIndex1
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
{state.activeStepIndex1 === 4 && (
|
{state.activeStepIndex1 === 4 && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user