cleanup open/closed logic
This commit is contained in:
@@ -266,7 +266,11 @@ function Inner(props: ReportDialogProps) {
|
|||||||
key={o.key}
|
key={o.key}
|
||||||
option={o}
|
option={o}
|
||||||
onSelect={() => {
|
onSelect={() => {
|
||||||
dispatch({type: 'selectCategory', option: o})
|
dispatch({
|
||||||
|
type: 'selectCategory',
|
||||||
|
option: o,
|
||||||
|
otherOption: getCategory('other').options[0],
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import {type AppBskyLabelerDefs, ComAtprotoModerationDefs} from '@atproto/api'
|
import {type AppBskyLabelerDefs} from '@atproto/api'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
OtherReportReasons,
|
||||||
type ReportOption,
|
type ReportOption,
|
||||||
type ReportOptionCategory,
|
type ReportOptionCategory,
|
||||||
} from './utils/useReportOptions'
|
} from './utils/useReportOptions'
|
||||||
@@ -19,6 +20,7 @@ export type ReportAction =
|
|||||||
| {
|
| {
|
||||||
type: 'selectCategory'
|
type: 'selectCategory'
|
||||||
option: ReportOptionCategory
|
option: ReportOptionCategory
|
||||||
|
otherOption: ReportOption
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'clearCategory'
|
type: 'clearCategory'
|
||||||
@@ -67,8 +69,10 @@ export function reducer(state: ReportState, action: ReportAction): ReportState {
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
selectedCategory: action.option,
|
selectedCategory: action.option,
|
||||||
activeStepIndex1: 2,
|
activeStepIndex1: action.option.key === 'other' ? 3 : 2,
|
||||||
detailsOpen: !!state.details,
|
selectedOption:
|
||||||
|
action.option.key === 'other' ? action.otherOption : undefined,
|
||||||
|
detailsOpen: state.selectedCategory?.key === 'other',
|
||||||
}
|
}
|
||||||
case 'clearCategory':
|
case 'clearCategory':
|
||||||
return {
|
return {
|
||||||
@@ -77,18 +81,14 @@ export function reducer(state: ReportState, action: ReportAction): ReportState {
|
|||||||
selectedOption: undefined,
|
selectedOption: undefined,
|
||||||
selectedLabeler: undefined,
|
selectedLabeler: undefined,
|
||||||
activeStepIndex1: 1,
|
activeStepIndex1: 1,
|
||||||
detailsOpen:
|
detailsOpen: false,
|
||||||
!!state.details ||
|
|
||||||
state.selectedOption?.reason === ComAtprotoModerationDefs.REASONOTHER,
|
|
||||||
}
|
}
|
||||||
case 'selectOption':
|
case 'selectOption':
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
selectedOption: action.option,
|
selectedOption: action.option,
|
||||||
activeStepIndex1: 3,
|
activeStepIndex1: 3,
|
||||||
detailsOpen:
|
detailsOpen: OtherReportReasons.has(action.option.reason),
|
||||||
!!state.details ||
|
|
||||||
action.option.reason === ComAtprotoModerationDefs.REASONOTHER,
|
|
||||||
}
|
}
|
||||||
case 'clearOption':
|
case 'clearOption':
|
||||||
return {
|
return {
|
||||||
@@ -96,9 +96,7 @@ export function reducer(state: ReportState, action: ReportAction): ReportState {
|
|||||||
selectedOption: undefined,
|
selectedOption: undefined,
|
||||||
selectedLabeler: undefined,
|
selectedLabeler: undefined,
|
||||||
activeStepIndex1: 2,
|
activeStepIndex1: 2,
|
||||||
detailsOpen:
|
detailsOpen: false,
|
||||||
!!state.details ||
|
|
||||||
state.selectedOption?.reason === ComAtprotoModerationDefs.REASONOTHER,
|
|
||||||
}
|
}
|
||||||
case 'selectLabeler':
|
case 'selectLabeler':
|
||||||
return {
|
return {
|
||||||
@@ -111,9 +109,6 @@ export function reducer(state: ReportState, action: ReportAction): ReportState {
|
|||||||
...state,
|
...state,
|
||||||
selectedLabeler: undefined,
|
selectedLabeler: undefined,
|
||||||
activeStepIndex1: 3,
|
activeStepIndex1: 3,
|
||||||
detailsOpen:
|
|
||||||
!!state.details ||
|
|
||||||
state.selectedOption?.reason === ComAtprotoModerationDefs.REASONOTHER,
|
|
||||||
}
|
}
|
||||||
case 'setDetails':
|
case 'setDetails':
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ export interface ReportOption {
|
|||||||
reason: ReasonType
|
reason: ReasonType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const OtherReportReasons = new Set<ReasonType | undefined>([
|
||||||
|
'com.atproto.moderation.defs#reasonOther',
|
||||||
|
'tools.ozone.report.defs#reasonChildSafetyOther',
|
||||||
|
'tools.ozone.report.defs#reasonViolenceOther',
|
||||||
|
'tools.ozone.report.defs#reasonSexualOther',
|
||||||
|
'tools.ozone.report.defs#reasonHarassmentOther',
|
||||||
|
'tools.ozone.report.defs#reasonMisleadingOther',
|
||||||
|
'tools.ozone.report.defs#reasonRuleOther',
|
||||||
|
'tools.ozone.report.defs#reasonChildSafetyOther',
|
||||||
|
])
|
||||||
|
|
||||||
export function useReportOptions() {
|
export function useReportOptions() {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user