From 5a9af9fdcef7126e886e1ba504f70e514f25fcc1 Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 9 May 2025 14:41:14 +0800 Subject: [PATCH] fix(rn): clicking on the avatar under the category will trigger two jump logics, fixed #3415 Signed-off-by: Innei --- apps/mobile/src/lib/navigation/Navigation.ts | 1 + .../src/lib/navigation/StackNavigation.tsx | 1 + apps/mobile/src/lib/navigation/types.ts | 25 ++++++------- .../entry-list/templates/EntrySocialItem.tsx | 36 +++++++++++-------- 4 files changed, 37 insertions(+), 26 deletions(-) diff --git a/apps/mobile/src/lib/navigation/Navigation.ts b/apps/mobile/src/lib/navigation/Navigation.ts index de502241d..d3d70f7f3 100644 --- a/apps/mobile/src/lib/navigation/Navigation.ts +++ b/apps/mobile/src/lib/navigation/Navigation.ts @@ -87,6 +87,7 @@ export class Navigation { screenOptions, }) } + private __pop() { const routes = jotaiStore.get(this.ctxValue.routesAtom) const lastRoute = routes.at(-1) diff --git a/apps/mobile/src/lib/navigation/StackNavigation.tsx b/apps/mobile/src/lib/navigation/StackNavigation.tsx index e4489206b..235b10528 100644 --- a/apps/mobile/src/lib/navigation/StackNavigation.tsx +++ b/apps/mobile/src/lib/navigation/StackNavigation.tsx @@ -105,6 +105,7 @@ const StateHandler = () => { }, [jotaiStore, nameAtom, navigation, navigationInstance]) return null } + const ScreenItemsMapper = () => { const chainCtxValue = use(ChainNavigationContext) const routes = useAtomValue(chainCtxValue.routesAtom) diff --git a/apps/mobile/src/lib/navigation/types.ts b/apps/mobile/src/lib/navigation/types.ts index 009771f9e..0b1ce03c0 100644 --- a/apps/mobile/src/lib/navigation/types.ts +++ b/apps/mobile/src/lib/navigation/types.ts @@ -5,7 +5,18 @@ export interface NavigationPushOptions { Component?: NavigationControllerView element?: React.ReactElement } -export type NavigationControllerViewExtraProps = { + +export interface NavigationControllerViewExtraProps + extends Pick< + ScreenProps, + | "sheetAllowedDetents" + | "sheetCornerRadius" + | "sheetExpandsWhenScrolledToEdge" + | "sheetElevation" + | "sheetGrabberVisible" + | "sheetInitialDetentIndex" + | "sheetLargestUndimmedDetentIndex" + > { /** * Unique identifier for the view. */ @@ -20,17 +31,7 @@ export type NavigationControllerViewExtraProps = { * Whether the view is transparent. */ transparent?: boolean -} & Pick< - ScreenProps, - | "sheetAllowedDetents" - | "sheetCornerRadius" - | "sheetExpandsWhenScrolledToEdge" - | "sheetElevation" - | "sheetGrabberVisible" - | "sheetInitialDetentIndex" - | "sheetLargestUndimmedDetentIndex" -> - +} // eslint-disable-next-line @typescript-eslint/no-empty-object-type export type NavigationControllerView

= FC

& NavigationControllerViewExtraProps export type NavigationControllerViewType = StackPresentationTypes diff --git a/apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx b/apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx index 1ce706528..5b728d008 100644 --- a/apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx +++ b/apps/mobile/src/modules/entry-list/templates/EntrySocialItem.tsx @@ -11,6 +11,7 @@ import { Galeria } from "@/src/components/ui/image/galeria" import { Image } from "@/src/components/ui/image/Image" import { ItemPressableStyle } from "@/src/components/ui/pressable/enum" import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable" +import { NativePressable } from "@/src/components/ui/pressable/NativePressable" import { VideoPlayer } from "@/src/components/ui/video/VideoPlayer" import { useNavigation } from "@/src/lib/navigation/hooks" import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen" @@ -53,6 +54,14 @@ export const EntrySocialItem = memo(({ entryId }: { entryId: string }) => { .filter(Boolean) || []) as string[] }, [entry]) + const navigationToFeedEntryList = useCallback(() => { + if (!entry) return + if (!entry.feedId) return + navigation.pushControllerView(FeedScreen, { + feedId: entry.feedId, + }) + }, [entry?.feedId, navigation]) + if (!entry) return const { description, publishedAt, media } = entry @@ -67,26 +76,25 @@ export const EntrySocialItem = memo(({ entryId }: { entryId: string }) => { {!entry.read && } - { - if (!entry.feedId) return - navigation.pushControllerView(FeedScreen, { - feedId: entry.feedId, - }) - }} - > + {entry.authorAvatar ? ( - + ) : ( feed && )} - + - - {entry.author || feed?.title} - + + + {entry.author || feed?.title} + + ยท