From c418fa1b3890ed78d22b629df54df36597b3bb23 Mon Sep 17 00:00:00 2001 From: Stephanie Freitag <stephanie.freitag@holi.team> Date: Tue, 18 Feb 2025 15:25:37 +0100 Subject: [PATCH] NOISSUE: remove broken prop from useLink --- core/auth/components/AlreadyHaveAccountText.tsx | 8 +------- core/auth/components/RecoverPasswordForm.tsx | 2 +- core/auth/screens/Login.tsx | 1 - core/navigation/components/HoliLink/index.tsx | 3 +-- core/navigation/components/HoliTextLink/index.tsx | 3 +-- .../components/HoliTextLink/index.web.tsx | 9 +-------- core/navigation/hooks/__tests__/useLink.test.ts | 9 --------- core/navigation/hooks/useLink.ts | 14 ++++---------- .../components/NotificationChallengesItem.tsx | 2 +- .../components/NotificationPollUpdatesItem.tsx | 2 +- .../components/NotificationReleaseInfoItem.tsx | 2 +- .../NotificationSpaceAppointmentBaseItem.tsx | 2 +- .../components/NotificationSpaceItem.tsx | 2 +- .../components/NotificationSpacePostItem.tsx | 2 +- .../components/NotificationWithUserAvatar.tsx | 2 +- 15 files changed, 16 insertions(+), 47 deletions(-) diff --git a/core/auth/components/AlreadyHaveAccountText.tsx b/core/auth/components/AlreadyHaveAccountText.tsx index 0ce8456b70..9453356691 100644 --- a/core/auth/components/AlreadyHaveAccountText.tsx +++ b/core/auth/components/AlreadyHaveAccountText.tsx @@ -7,16 +7,11 @@ import { Text } from 'holi-bricks/components/text' import { View } from 'react-native' export interface AlreadyHaveAccountTextProps { - mobileNavigateBackFirst?: boolean trackingEvent: TrackingEvent onPress?(): void } -const AlreadyHaveAccountText = ({ - mobileNavigateBackFirst = false, - trackingEvent, - onPress, -}: AlreadyHaveAccountTextProps) => { +const AlreadyHaveAccountText = ({ trackingEvent, onPress }: AlreadyHaveAccountTextProps) => { const { t } = useTranslation() return ( @@ -28,7 +23,6 @@ const AlreadyHaveAccountText = ({ onPress={onPress} href="/login" size="sm" - mobileNavigateBackFirst={mobileNavigateBackFirst} trackingEvent={trackingEvent} > {t('auth.login')} diff --git a/core/auth/components/RecoverPasswordForm.tsx b/core/auth/components/RecoverPasswordForm.tsx index b2a4c30c3d..b1fd18f671 100644 --- a/core/auth/components/RecoverPasswordForm.tsx +++ b/core/auth/components/RecoverPasswordForm.tsx @@ -76,7 +76,7 @@ const RecoverPasswordForm = (props: RecoverPasswordFormProps) => { {!props.webview && ( <> <HoliGap size="s" /> - <AlreadyHaveAccountText mobileNavigateBackFirst trackingEvent={TrackingEvent.Auth.LoginButtonPressed} /> + <AlreadyHaveAccountText trackingEvent={TrackingEvent.Auth.LoginButtonPressed} /> <HoliGap size="l" /> <HoliHeading level="2" align="center"> {t('auth.login.signUp.link.headline')} diff --git a/core/auth/screens/Login.tsx b/core/auth/screens/Login.tsx index c847e203cf..e7b876d159 100644 --- a/core/auth/screens/Login.tsx +++ b/core/auth/screens/Login.tsx @@ -120,7 +120,6 @@ const Login = () => { href="/forgotPassword" size="sm" textAlign="center" - mobileNavigateBackFirst trackingEvent={TrackingEvent.Auth.ForgotPasswordButtonPressed} > {t('auth.login.link.forgotPassword')} diff --git a/core/navigation/components/HoliLink/index.tsx b/core/navigation/components/HoliLink/index.tsx index eb2aa4e55b..410d08668c 100644 --- a/core/navigation/components/HoliLink/index.tsx +++ b/core/navigation/components/HoliLink/index.tsx @@ -11,11 +11,10 @@ export const HoliLink = ({ external, onPress, children, - mobileNavigateBackFirst, isFullHeight = false, testID = 'link', }: PropsWithChildren<HoliLinkProps>) => { - const handleLinkPress = useLink({ href, external, onPress, mobileNavigateBackFirst }) + const handleLinkPress = useLink({ href, external, onPress }) return ( <Pressable diff --git a/core/navigation/components/HoliTextLink/index.tsx b/core/navigation/components/HoliTextLink/index.tsx index 7d8e191ad9..36ff618305 100644 --- a/core/navigation/components/HoliTextLink/index.tsx +++ b/core/navigation/components/HoliTextLink/index.tsx @@ -11,12 +11,11 @@ export const HoliTextLink = ({ external, onPress, children, - mobileNavigateBackFirst, color, size, textAlign, }: PropsWithChildren<HoliTextLinkProps>) => { - const handleLinkPress = useLink({ href, external, onPress, mobileNavigateBackFirst }) + const handleLinkPress = useLink({ href, external, onPress }) return ( <TextLink size={size} color={color} textAlign={textAlign} onPress={handleLinkPress} aria-label={label}> diff --git a/core/navigation/components/HoliTextLink/index.web.tsx b/core/navigation/components/HoliTextLink/index.web.tsx index 3d858988fb..8a4f4677c9 100644 --- a/core/navigation/components/HoliTextLink/index.web.tsx +++ b/core/navigation/components/HoliTextLink/index.web.tsx @@ -11,20 +11,13 @@ export const HoliTextLink = ({ external, onPress, children, - mobileNavigateBackFirst, color, textAlign, size, }: PropsWithChildren<HoliTextLinkProps>) => { return ( <TextLink size={size} color={color} textAlign={textAlign} role="none"> - <HoliLink - href={href} - label={label} - external={external} - onPress={onPress} - mobileNavigateBackFirst={mobileNavigateBackFirst} - > + <HoliLink href={href} label={label} external={external} onPress={onPress}> {children} </HoliLink> </TextLink> diff --git a/core/navigation/hooks/__tests__/useLink.test.ts b/core/navigation/hooks/__tests__/useLink.test.ts index 73ac82e950..858a268050 100644 --- a/core/navigation/hooks/__tests__/useLink.test.ts +++ b/core/navigation/hooks/__tests__/useLink.test.ts @@ -79,15 +79,6 @@ describe('useLink', () => { expect(mockOpenURL).toHaveBeenCalledWith('/') }) - it('should navigate back first on mobile', async () => { - const { result } = renderHook(() => useLink({ href: '/spaces', mobileNavigateBackFirst: true })) - - result.current(testEvent) - - expect(mockNavigateBack).toHaveBeenCalled() - await waitFor(() => expect(mockNavigate).toHaveBeenCalledWith('//spaces')) - }) - it('should ignore domain and locale path param on mobile', () => { const originalPlatform = Platform.OS Platform.OS = 'android' diff --git a/core/navigation/hooks/useLink.ts b/core/navigation/hooks/useLink.ts index c5ccbc14f0..54cee39689 100644 --- a/core/navigation/hooks/useLink.ts +++ b/core/navigation/hooks/useLink.ts @@ -9,11 +9,10 @@ export interface UseLinkProps { /** if given, `onPress` will be executed before opening href (if given). if `onPress` returns `false` (synchronously, required for web) event propagation will be stopped */ onPress?: (event: React.SyntheticEvent | GestureResponderEvent) => unknown | Promise<unknown> external?: boolean - mobileNavigateBackFirst?: boolean } -const useLink = ({ onPress, external, href, mobileNavigateBackFirst }: UseLinkProps) => { - const { navigate, navigateBack } = useRouting() +const useLink = ({ onPress, external, href }: UseLinkProps) => { + const { navigate } = useRouting() return useCallback( async (event: React.SyntheticEvent | GestureResponderEvent) => { @@ -31,17 +30,12 @@ const useLink = ({ onPress, external, href, mobileNavigateBackFirst }: UseLinkPr if (Platform.OS === 'ios' || Platform.OS === 'android') { // If the platform is mobile and the link domain matches our app's domain, navigate to the route instead of opening the link const route = '/' + href.replace(/https:\/\/(app\.holi\.social|staging\.dev\.holi\.social)(\/(en|de))?\/?/, '') - if (mobileNavigateBackFirst) { - navigateBack() - setTimeout(() => navigate(route), 300) - } else { - navigate(route) - } + navigate(route) } else { navigate(href) } }, - [external, href, mobileNavigateBackFirst, navigate, navigateBack, onPress] + [external, href, navigate, onPress] ) } diff --git a/core/screens/notifications/components/NotificationChallengesItem.tsx b/core/screens/notifications/components/NotificationChallengesItem.tsx index f10ecf98d2..01542e9089 100644 --- a/core/screens/notifications/components/NotificationChallengesItem.tsx +++ b/core/screens/notifications/components/NotificationChallengesItem.tsx @@ -34,7 +34,7 @@ export const NotificationChallengesItem = ({ paddingVertical: 12, }} > - <HoliLink href={route} label={'notification'} mobileNavigateBackFirst> + <HoliLink href={route} label={'notification'}> <View style={styles.link}> <HoliIcon icon={challengesColored} size={40} /> <View style={styles.content}> diff --git a/core/screens/notifications/components/NotificationPollUpdatesItem.tsx b/core/screens/notifications/components/NotificationPollUpdatesItem.tsx index 9ccc26e1d1..ccacbb9a55 100644 --- a/core/screens/notifications/components/NotificationPollUpdatesItem.tsx +++ b/core/screens/notifications/components/NotificationPollUpdatesItem.tsx @@ -21,7 +21,7 @@ const NotificationPollUpdatesItem = ({ notification }: NotificationProps<Notific return ( <View> - <HoliLink href={`/insights/${poll.insightId}`} label={poll.title} mobileNavigateBackFirst> + <HoliLink href={`/insights/${poll.insightId}`} label={poll.title}> <View style={styles.link}> <View style={styles.image}> <HoliLocalImage diff --git a/core/screens/notifications/components/NotificationReleaseInfoItem.tsx b/core/screens/notifications/components/NotificationReleaseInfoItem.tsx index 005d3289df..6b27dac8ed 100644 --- a/core/screens/notifications/components/NotificationReleaseInfoItem.tsx +++ b/core/screens/notifications/components/NotificationReleaseInfoItem.tsx @@ -24,7 +24,7 @@ const NotificationReleaseInfoItem: React.FC<NotificationProps<NotificationReleas return ( <View style={style} testID={testID}> - <HoliLink href={`/posts/${post?.id}`} label={post?.title} mobileNavigateBackFirst> + <HoliLink href={`/posts/${post?.id}`} label={post?.title}> <View style={styles.link}> <HoliLocalImage imageSource={require('@holi/ui/assets/img/holi/holi_brandmark.svg')} diff --git a/core/screens/notifications/components/NotificationSpaceAppointmentBaseItem.tsx b/core/screens/notifications/components/NotificationSpaceAppointmentBaseItem.tsx index 68fc1a3765..f5cbdc7e90 100644 --- a/core/screens/notifications/components/NotificationSpaceAppointmentBaseItem.tsx +++ b/core/screens/notifications/components/NotificationSpaceAppointmentBaseItem.tsx @@ -35,7 +35,7 @@ export const NotificationSpaceAppointmentBaseItem = ({ paddingVertical: 12, }} > - <HoliLink href={link ?? '/'} label={space.title} mobileNavigateBackFirst> + <HoliLink href={link ?? '/'} label={space.title}> <View style={styles.link}> <SpaceAvatar space={space} size="sm" /> diff --git a/core/screens/notifications/components/NotificationSpaceItem.tsx b/core/screens/notifications/components/NotificationSpaceItem.tsx index 6723aa98e5..d772f2a551 100644 --- a/core/screens/notifications/components/NotificationSpaceItem.tsx +++ b/core/screens/notifications/components/NotificationSpaceItem.tsx @@ -46,7 +46,7 @@ const NotificationSpaceItem = ({ return ( <View style={style} testID={testID}> - <HoliLink href={href} label={title} mobileNavigateBackFirst> + <HoliLink href={href} label={title}> <View style={styles.container}> <View style={styles.imageContainer}> <SpaceAvatar space={notification.options.space} size="sm" /> diff --git a/core/screens/notifications/components/NotificationSpacePostItem.tsx b/core/screens/notifications/components/NotificationSpacePostItem.tsx index 6b187a171b..d33cdf7033 100644 --- a/core/screens/notifications/components/NotificationSpacePostItem.tsx +++ b/core/screens/notifications/components/NotificationSpacePostItem.tsx @@ -21,7 +21,7 @@ const NotificationSpacePostItem = ({ notification, style, testID = '' }: Notific return ( <View style={style} testID={testID}> - <HoliLink href={`/spaces/${space.name}?tab=updates`} label={space.title} mobileNavigateBackFirst> + <HoliLink href={`/spaces/${space.name}?tab=updates`} label={space.title}> <View style={styles.link}> <SpaceAvatar space={space} size="sm" /> diff --git a/core/screens/notifications/components/NotificationWithUserAvatar.tsx b/core/screens/notifications/components/NotificationWithUserAvatar.tsx index 9c724a16b4..37363d8609 100644 --- a/core/screens/notifications/components/NotificationWithUserAvatar.tsx +++ b/core/screens/notifications/components/NotificationWithUserAvatar.tsx @@ -38,7 +38,7 @@ const NotificationWithUserAvatar = ({ return ( <View style={style} testID={testID}> - <HoliLink href={href} label={userFullName} mobileNavigateBackFirst> + <HoliLink href={href} label={userFullName}> <View style={styles.link}> <Avatar imgPlaceholder={avatarBlurhash} -- GitLab