Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(llm): ledger sync navigation fixes #7753

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tough-ads-dance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

LLM - Ledger sync small navigation fixes
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { ManageInstancesProcess } from "./screens/ManageInstances/ManageInstance
import { WalletSyncManageInstanceDeletionSuccess } from "./screens/ManageInstances/DeletionSuccess";
import { LedgerSyncDeepLinkHandler } from "./screens/LedgerSyncDeepLinkHandler";
import { NavigationHeaderCloseButton } from "~/components/NavigationHeaderCloseButton";
import { useClose } from "./hooks/useClose";

const Stack = createStackNavigator<WalletSyncNavigatorStackParamList>();

Expand All @@ -24,6 +25,7 @@ export default function WalletSyncNavigator() {
const stackNavConfig = useMemo(() => getStackNavigatorConfig(colors), [colors]);
const { t } = useTranslation();
useInitMemberCredentials();
const close = useClose();

return (
<Stack.Navigator screenOptions={stackNavConfig}>
Expand All @@ -49,7 +51,7 @@ export default function WalletSyncNavigator() {
options={{
title: "",
headerLeft: () => null,
headerRight: () => <NavigationHeaderCloseButton />,
headerRight: () => <NavigationHeaderCloseButton onPress={close} />,
}}
/>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { useNavigation } from "@react-navigation/native";
import { useDispatch, useSelector } from "react-redux";
import { setFromLedgerSyncOnboarding } from "~/actions/settings";
import { BaseNavigatorStackParamList } from "~/components/RootNavigator/types/BaseNavigator";
import {
RootNavigationComposite,
StackNavigatorNavigation,
} from "~/components/RootNavigator/types/helpers";
import { NavigatorName } from "~/const";
import { isFromLedgerSyncOnboardingSelector } from "~/reducers/settings";

export function useClose() {
const navigationOnbarding =
useNavigation<RootNavigationComposite<StackNavigatorNavigation<BaseNavigatorStackParamList>>>();
const isFromLedgerSyncOnboarding = useSelector(isFromLedgerSyncOnboardingSelector);
const dispatch = useDispatch();

const close = () => {
if (isFromLedgerSyncOnboarding) {
dispatch(setFromLedgerSyncOnboarding(false));
}
navigationOnbarding.replace(NavigatorName.Base, {
screen: NavigatorName.Main,
});
};

return close;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import { useMutation } from "@tanstack/react-query";
import { QueryKey } from "./type.hooks";
import { useCloudSyncSDK } from "./useWatchWalletSync";
import { walletSyncUpdate } from "@ledgerhq/live-wallet/store";
import { useCurrentStep } from "./useCurrentStep";
import { Steps } from "../types/Activation";

export function useDestroyTrustchain() {
const dispatch = useDispatch();
const cloudSyncSDK = useCloudSyncSDK();
const sdk = useTrustchainSdk();
const trustchain = useSelector(trustchainSelector);
const memberCredentials = useSelector(memberCredentialsSelector);
const { setCurrentStep } = useCurrentStep();

const deleteMutation = useMutation({
mutationFn: async () => {
Expand All @@ -29,6 +32,7 @@ export function useDestroyTrustchain() {
onSuccess: () => {
dispatch(resetTrustchainStore());
dispatch(walletSyncUpdate(null, 0));
setCurrentStep(Steps.Activation);
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import React from "react";
import { Success } from "../../components/Success";
import { useTranslation } from "react-i18next";
import {
BaseComposite,
RootNavigationComposite,
StackNavigatorNavigation,
StackNavigatorProps,
} from "~/components/RootNavigator/types/helpers";
import { BaseComposite, StackNavigatorProps } from "~/components/RootNavigator/types/helpers";
import { WalletSyncNavigatorStackParamList } from "~/components/RootNavigator/types/WalletSyncNavigator";

import { NavigatorName, ScreenName } from "~/const";
import { useDispatch, useSelector } from "react-redux";
import { isFromLedgerSyncOnboardingSelector } from "~/reducers/settings";
import { useNavigation } from "@react-navigation/native";
import { BaseNavigatorStackParamList } from "~/components/RootNavigator/types/BaseNavigator";
import { setFromLedgerSyncOnboarding } from "~/actions/settings";
import { AnalyticsButton, AnalyticsFlow, AnalyticsPage } from "../../hooks/useLedgerSyncAnalytics";
import { track } from "~/analytics";
import { setLedgerSyncActivateDrawer } from "~/actions/walletSync";
import { Steps } from "../../types/Activation";
import { useCurrentStep } from "../../hooks/useCurrentStep";
import { useClose } from "../../hooks/useClose";

type Props = BaseComposite<
StackNavigatorProps<WalletSyncNavigatorStackParamList, ScreenName.WalletSyncSuccess>
Expand All @@ -35,10 +29,9 @@ export function ActivationSuccess({ navigation, route }: Props) {
const dispatch = useDispatch();
const { setCurrentStep } = useCurrentStep();

const navigationOnbarding =
useNavigation<RootNavigationComposite<StackNavigatorNavigation<BaseNavigatorStackParamList>>>();
const close = useClose();

function syncAnother(): void {
function onSyncAnother(): void {
track("button_clicked", {
button: AnalyticsButton.SyncWithAnotherLedgerLive,
page,
Expand All @@ -54,22 +47,13 @@ export function ActivationSuccess({ navigation, route }: Props) {
dispatch(setLedgerSyncActivateDrawer(true));
}

function close(): void {
function onClose(): void {
track("button_clicked", {
button: AnalyticsButton.Close,
page,
flow: AnalyticsFlow.LedgerSync,
});
if (isFromLedgerSyncOnboarding) {
dispatch(setFromLedgerSyncOnboarding(false));
navigationOnbarding.navigate(NavigatorName.Base, {
screen: NavigatorName.Main,
});
} else {
navigation.navigate(NavigatorName.Settings, {
screen: ScreenName.GeneralSettings,
});
}
close();
}

return (
Expand All @@ -78,11 +62,11 @@ export function ActivationSuccess({ navigation, route }: Props) {
desc={t(desc)}
mainButton={{
label: t("walletSync.success.syncAnother"),
onPress: syncAnother,
onPress: onSyncAnother,
}}
secondaryButton={{
label: t("walletSync.success.close"),
onPress: close,
onPress: onClose,
}}
analyticsPage={page}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useAppDeviceAction } from "~/hooks/deviceActions";
import { AppResult } from "@ledgerhq/live-common/hw/actions/app";
import { WalletSyncNavigatorStackParamList } from "~/components/RootNavigator/types/WalletSyncNavigator";
import { TRUSTCHAIN_APP_NAME } from "@ledgerhq/hw-trustchain";
import { SafeAreaView } from "react-native-safe-area-context";

type NavigationProps = BaseComposite<
StackNavigatorProps<
Expand Down Expand Up @@ -100,7 +101,7 @@ const WalletSyncActivationDeviceSelection: React.FC<ChooseDeviceProps> = ({
if (!isFocused) return null;

return (
<>
<SafeAreaView edges={["top", "left", "right"]} style={{ flex: 1 }}>
<TrackScreen category="Manager" name="ChooseDevice" />
{!isHeaderOverridden ? (
<Flex px={16} pb={8}>
Expand Down Expand Up @@ -128,7 +129,7 @@ const WalletSyncActivationDeviceSelection: React.FC<ChooseDeviceProps> = ({
request={request}
onError={onError}
/>
</>
</SafeAreaView>
);
};

Expand Down
Loading