diff options
author | dan <dan.abramov@gmail.com> | 2024-11-18 17:44:45 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-18 17:44:45 +0000 |
commit | 924f1e0e7f097b38081256920c71ddcc3f4ec85f (patch) | |
tree | b121f9a345a022efe892759c723d00ad432d19a8 /src/components/moderation | |
parent | 0b38c77faa71dbc777d3d0162b86cb3e8695ff99 (diff) | |
download | voidsky-924f1e0e7f097b38081256920c71ddcc3f4ec85f.tar.zst |
Optimize ContentHider (#6501)
Diffstat (limited to 'src/components/moderation')
-rw-r--r-- | src/components/moderation/ContentHider.tsx | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/components/moderation/ContentHider.tsx b/src/components/moderation/ContentHider.tsx index 67aef67b4..69193592a 100644 --- a/src/components/moderation/ContentHider.tsx +++ b/src/components/moderation/ContentHider.tsx @@ -32,6 +32,37 @@ export function ContentHider({ 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() const {gtMobile} = useBreakpoints() @@ -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) @@ -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} /> |