Skip to content

Commit

Permalink
Optimize ContentHider (#6501)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored Nov 18, 2024
1 parent 0b38c77 commit 924f1e0
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions src/components/moderation/ContentHider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,37 @@ export function ContentHider({
ignoreMute?: boolean
style?: StyleProp<ViewStyle>
childContainerStyle?: StyleProp<ViewStyle>
}>) {
const blur = modui?.blurs[0]
if (!blur || (ignoreMute && isJustAMute(modui))) {
return (
<View testID={testID} style={style}>
{children}
</View>
)
}
return (
<ContentHiderActive
testID={testID}
modui={modui}
style={style}
childContainerStyle={childContainerStyle}>
{children}
</ContentHiderActive>
)
}

function ContentHiderActive({
testID,
modui,
style,
childContainerStyle,
children,
}: React.PropsWithChildren<{
testID?: string
modui: ModerationUI
style?: StyleProp<ViewStyle>
childContainerStyle?: StyleProp<ViewStyle>
}>) {
const t = useTheme()
const {_} = useLingui()
Expand All @@ -40,7 +71,6 @@ export function ContentHider({
const {labelDefs} = useLabelDefinitions()
const globalLabelStrings = useGlobalLabelStrings()
const {i18n} = useLingui()

const blur = modui?.blurs[0]
const desc = useModerationCauseDescription(blur)

Expand Down Expand Up @@ -99,14 +129,6 @@ export function ContentHider({
globalLabelStrings,
])

if (!blur || (ignoreMute && isJustAMute(modui))) {
return (
<View testID={testID} style={style}>
{children}
</View>
)
}

return (
<View testID={testID} style={[a.overflow_hidden, style]}>
<ModerationDetailsDialog control={control} modcause={blur} />
Expand Down

0 comments on commit 924f1e0

Please sign in to comment.