From 6dab3acaa1732df0acee9e7b822e38c1728a973a Mon Sep 17 00:00:00 2001 From: ak-ledger Date: Fri, 24 Nov 2023 17:00:56 +0100 Subject: [PATCH 1/3] fix(stax): loading multiple invalid pictures and going back will navigate on correct page --- .../src/components/RootNavigator/CustomImageNavigator.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/CustomImageNavigator.tsx b/apps/ledger-live-mobile/src/components/RootNavigator/CustomImageNavigator.tsx index 1b6f735fad45..fb913412d483 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/CustomImageNavigator.tsx +++ b/apps/ledger-live-mobile/src/components/RootNavigator/CustomImageNavigator.tsx @@ -12,6 +12,7 @@ import Step0Welcome from "../../screens/CustomImage/Step0Welcome"; import PreviewPreEdit from "../../screens/CustomImage/PreviewPreEdit"; import PreviewPostEdit from "../../screens/CustomImage/PreviewPostEdit"; import NFTGallerySelector from "../../screens/CustomImage/NFTGallerySelector"; +import { NavigationHeaderBackButton } from "../NavigationHeaderBackButton"; import { CustomImageNavigatorParamList } from "./types/CustomImageNavigator"; export default function CustomImageNavigator() { @@ -47,11 +48,11 @@ export default function CustomImageNavigator() { ({ title: "", - headerLeft: undefined, + headerLeft: () => navigation.popToTop()} />, gestureEnabled: false, - }} + })} /> Date: Fri, 24 Nov 2023 17:29:50 +0100 Subject: [PATCH 2/3] fix(stax): add changelog --- .changeset/pretty-poems-lie.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/pretty-poems-lie.md diff --git a/.changeset/pretty-poems-lie.md b/.changeset/pretty-poems-lie.md new file mode 100644 index 000000000000..d589bd04b7a9 --- /dev/null +++ b/.changeset/pretty-poems-lie.md @@ -0,0 +1,5 @@ +--- +"live-mobile": patch +--- + +Loading multiple invalid picture for stax and using the back arrow navigate to the correct page From 5e7b55869e9a91e7dd6cf1d7f1a8a0ced4948909 Mon Sep 17 00:00:00 2001 From: ak-ledger Date: Tue, 28 Nov 2023 13:33:10 +0100 Subject: [PATCH 3/3] fix(stax): stax image loader only allow one error page in navigation --- .../RootNavigator/CustomImageNavigator.tsx | 7 +++--- .../src/screens/CustomImage/ErrorScreen.tsx | 24 +++++++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/apps/ledger-live-mobile/src/components/RootNavigator/CustomImageNavigator.tsx b/apps/ledger-live-mobile/src/components/RootNavigator/CustomImageNavigator.tsx index fb913412d483..1b6f735fad45 100644 --- a/apps/ledger-live-mobile/src/components/RootNavigator/CustomImageNavigator.tsx +++ b/apps/ledger-live-mobile/src/components/RootNavigator/CustomImageNavigator.tsx @@ -12,7 +12,6 @@ import Step0Welcome from "../../screens/CustomImage/Step0Welcome"; import PreviewPreEdit from "../../screens/CustomImage/PreviewPreEdit"; import PreviewPostEdit from "../../screens/CustomImage/PreviewPostEdit"; import NFTGallerySelector from "../../screens/CustomImage/NFTGallerySelector"; -import { NavigationHeaderBackButton } from "../NavigationHeaderBackButton"; import { CustomImageNavigatorParamList } from "./types/CustomImageNavigator"; export default function CustomImageNavigator() { @@ -48,11 +47,11 @@ export default function CustomImageNavigator() { ({ + options={{ title: "", - headerLeft: () => navigation.popToTop()} />, + headerLeft: undefined, gestureEnabled: false, - })} + }} /> { +const ErrorScreen = ({ route, navigation }: NavigationProps) => { const [isModalOpened, setIsModalOpened] = useState(false); const { params } = route; const { error, device } = params; + // Only keep 1 instance of error page in the navigation + useEffect(() => { + const navigationState = navigation.getState(); + const { index, routes } = navigationState; + const firstErrorPageIndex = routes.findIndex( + (route: { name: string }, id: number) => + route.name === ScreenName.CustomImageErrorScreen && index !== id, + ); + + if (firstErrorPageIndex !== -1) { + const filteredRoutes = routes.filter((route, id) => id !== firstErrorPageIndex); + + navigation.reset({ + ...navigationState, + index: filteredRoutes.length - 1, + routes: filteredRoutes, + }); + } + }, [navigation]); + const { t } = useTranslation(); const closeModal = useCallback(() => {