From 1b0fbd503e867729e42e85d128fdac4fafa9372d Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 4 Nov 2025 15:43:08 +0200 Subject: [PATCH] Remove use of `flatten` where possible (#9325) * remove use of flatten where possible * restore flatten where it says it's needed * missing utils alpha --- src/components/Button.tsx | 10 ++++------ src/components/Dialog/index.web.tsx | 8 ++++---- src/components/FeedCard.tsx | 2 +- src/components/IconCircle.tsx | 13 ++----------- src/components/LabelingServiceCard/index.tsx | 2 +- src/components/Link.tsx | 2 +- src/components/Lists.tsx | 4 ++-- src/components/Loader.tsx | 9 ++------- src/components/Loader.web.tsx | 4 ++-- src/components/PolicyUpdateOverlay/Overlay.tsx | 12 ++++++------ src/components/PostControls/index.tsx | 15 ++++++++------- src/components/ProfileCard.tsx | 2 +- src/components/RichText.tsx | 10 +++------- src/components/Tooltip/index.web.tsx | 8 ++++---- src/components/Typography.tsx | 6 +++--- src/components/WelcomeModal.tsx | 6 +++--- src/components/dms/EmojiReactionPicker.web.tsx | 4 ++-- src/components/dms/ReportDialog.tsx | 2 +- src/components/forms/Toggle.tsx | 5 ++--- src/components/icons/TEMPLATE.tsx | 2 +- .../Messages/components/MessageInput.web.tsx | 6 +++--- src/screens/Onboarding/Layout.tsx | 13 ++----------- .../Profile/components/ProfileFeedHeader.tsx | 2 +- src/screens/ProfileList/components/Header.tsx | 2 +- src/screens/StarterPack/StarterPackScreen.tsx | 4 +--- src/screens/VideoFeed/index.tsx | 2 +- src/view/com/util/images/ImageLayoutGrid.tsx | 4 ++-- src/view/icons/Logo.tsx | 5 +++-- 28 files changed, 67 insertions(+), 97 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index ad55e16ca2..783a61993b 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -7,7 +7,6 @@ import { Pressable, type PressableProps, type StyleProp, - StyleSheet, type TargetedEvent, type TextProps, type TextStyle, @@ -512,8 +511,6 @@ export const Button = React.forwardRef( [state, variant, color, size, disabled], ) - const flattenedBaseStyles = flatten([baseStyles, style]) - return ( ( a.align_center, a.justify_center, a.curve_continuous, - flattenedBaseStyles, + baseStyles, + style, ...(state.hovered || state.pressed - ? [hoverStyles, flatten(hoverStyleProp)] + ? [hoverStyles, hoverStyleProp] : []), ]} onPressIn={onPressIn} @@ -726,7 +724,7 @@ export function useSharedButtonTextStyles() { baseStyles.push(a.text_xs, a.leading_snug, a.font_semi_bold) } - return StyleSheet.flatten(baseStyles) + return flatten(baseStyles) }, [t, variant, color, size, disabled]) } diff --git a/src/components/Dialog/index.web.tsx b/src/components/Dialog/index.web.tsx index 1d62cbfdcd..781adedee5 100644 --- a/src/components/Dialog/index.web.tsx +++ b/src/components/Dialog/index.web.tsx @@ -16,7 +16,7 @@ import {RemoveScrollBar} from 'react-remove-scroll-bar' import {logger} from '#/logger' import {useA11y} from '#/state/a11y' import {useDialogStateControlContext} from '#/state/dialogs' -import {atoms as a, flatten, useBreakpoints, useTheme, web} from '#/alf' +import {atoms as a, useBreakpoints, useTheme, web} from '#/alf' import {Button, ButtonIcon} from '#/components/Button' import {Context} from '#/components/Dialog/context' import { @@ -180,7 +180,7 @@ export function Inner({ onClick={stopPropagation} onStartShouldSetResponder={_ => true} onTouchEnd={stopPropagation} - style={flatten([ + style={[ a.relative, a.rounded_md, a.w_full, @@ -195,7 +195,7 @@ export function Inner({ }, !reduceMotionEnabled && a.zoom_fade_in, style, - ])}> + ]}> {footer} diff --git a/src/components/FeedCard.tsx b/src/components/FeedCard.tsx index ed7208779a..c5e6200527 100644 --- a/src/components/FeedCard.tsx +++ b/src/components/FeedCard.tsx @@ -186,7 +186,7 @@ export function Description({ return rt }, [description]) if (!rt) return null - return + return } export function DescriptionPlaceholder() { diff --git a/src/components/IconCircle.tsx b/src/components/IconCircle.tsx index 286dc28370..2e3af7d84f 100644 --- a/src/components/IconCircle.tsx +++ b/src/components/IconCircle.tsx @@ -2,7 +2,6 @@ import {View} from 'react-native' import { atoms as a, - flatten, type TextStyleProp, useTheme, type ViewStyleProp, @@ -33,17 +32,9 @@ export function IconCircle({ height: size === 'lg' ? 52 : 64, backgroundColor: t.palette.primary_50, }, - flatten(style), + style, ]}> - + ) } diff --git a/src/components/LabelingServiceCard/index.tsx b/src/components/LabelingServiceCard/index.tsx index ecb47a7588..7c7c8a8ba8 100644 --- a/src/components/LabelingServiceCard/index.tsx +++ b/src/components/LabelingServiceCard/index.tsx @@ -55,7 +55,7 @@ export function Description({value, handle}: {value?: string; handle: string}) { const {_} = useLingui() return value ? ( - + ) : ( diff --git a/src/components/Link.tsx b/src/components/Link.tsx index 2b533b5998..ce970d9659 100644 --- a/src/components/Link.tsx +++ b/src/components/Link.tsx @@ -296,7 +296,7 @@ export function Link({ return ( ) { return ( + style={[a.pb_sm, a.text_4xl, a.font_semi_bold, a.leading_tight, style]}> {children} ) @@ -245,7 +238,5 @@ export function DescriptionText({ style, }: React.PropsWithChildren) { const t = useTheme() - return ( -

{children}

- ) + return

{children}

} diff --git a/src/screens/Profile/components/ProfileFeedHeader.tsx b/src/screens/Profile/components/ProfileFeedHeader.tsx index 821f2eea4d..db548a6662 100644 --- a/src/screens/Profile/components/ProfileFeedHeader.tsx +++ b/src/screens/Profile/components/ProfileFeedHeader.tsx @@ -481,7 +481,7 @@ function DialogInner({ - + {typeof likeCount === 'number' && ( diff --git a/src/screens/ProfileList/components/Header.tsx b/src/screens/ProfileList/components/Header.tsx index fe4b33c753..1dc94fbb65 100644 --- a/src/screens/ProfileList/components/Header.tsx +++ b/src/screens/ProfileList/components/Header.tsx @@ -200,7 +200,7 @@ export function Header({ {descriptionRT ? ( - + ) : null} diff --git a/src/screens/StarterPack/StarterPackScreen.tsx b/src/screens/StarterPack/StarterPackScreen.tsx index 10fa827603..18113c83e1 100644 --- a/src/screens/StarterPack/StarterPackScreen.tsx +++ b/src/screens/StarterPack/StarterPackScreen.tsx @@ -458,9 +458,7 @@ function Header({ {!hasSession || richText || joinedAllTimeCount >= 25 ? ( - {richText ? ( - - ) : null} + {richText ? : null} {!hasSession ? (