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

πŸ› LLM - Improve Ledger Sync when backup deleted on multiple instances #8466

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/beige-rings-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

LLM - Ledger Sync improve error message when deleting backup on multiple instances at the same time
5 changes: 5 additions & 0 deletions apps/ledger-live-mobile/src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -6929,6 +6929,11 @@
"cancel": "Keep sync",
"title": "Sure you want delete sync?",
"desc": "Your crypto accounts on different phones and computers will stop being in sync. This does not impact your funds in any way."
},
"error": {
"title": "This app is no longer synced",
"description": "Turn on Ledger Sync on either this Ledger Live or the one you're syncing with.",
"cta": "Turn on Ledger Sync"
}
},
"manageInstances": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum AnalyticsPage {
ManageBackup = "Delete sync",
ConfirmDeleteBackup = "Confirm delete sync",
DeleteBackupSuccess = "Delete sync success",
DeleteBackupError = "Delete sync error",
SyncWithNoKey = "Scan attempt with no sync",
LedgerSyncActivated = "Ledger Sync activated",
AutoRemove = "Can’t remove current instance",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export enum ErrorReason {
NO_BACKUP = "no-backup",
NO_BACKUP_ONBOARDING_DEVICE = "no-backup-onboarding-device",
NO_BACKUP_ONBOARDING_QRCODE = "no-backup-onboarding-qrcode",
NO_TRUSTCHAIN = "no-trustchain",
}

export interface ErrorConfig {
Expand Down Expand Up @@ -225,6 +226,18 @@ export function useSpecificError({ primaryAction, secondaryAction }: SpecificPro
ContinueWihtoutSync({ page: AnalyticsPage.OnBoardingDeviceNoBackup, hasFlow: false });
},
},
[ErrorReason.NO_TRUSTCHAIN]: {
icon: <Icons.DeleteCircleFill size={"L"} color={colors.error.c60} />,
title: t("walletSync.walletSyncActivated.manageKey.error.title"),
description: t("walletSync.walletSyncActivated.manageKey.error.description"),
cta: t("walletSync.walletSyncActivated.manageKey.error.cta"),
analyticsPage: AnalyticsPage.DeleteBackupError,
buttonType: "main" as ButtonProps["type"],
primaryAction: () => {
primaryAction();
onCreate({ page: AnalyticsPage.DeleteBackupError, hasFlow: false });
},
},
};

const getErrorConfig = (error: ErrorReason) => errorConfig[error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ import { Flex, InfiniteLoader } from "@ledgerhq/native-ui";

import { ConfirmManageKey } from "../../components/ManageKey/Confirm";
import { HookResult } from "./useManageKeyDrawer";
import { isNoTrustchainError } from "../../utils/errors";
import { SpecificError } from "../../components/Error/SpecificError";
import { ErrorReason } from "../../hooks/useSpecificError";

const ManageKeyDrawer = ({
isDrawerVisible,
handleClose,
deleteMutation,
onClickConfirm,
handleCancel,
onCreateKey,
}: HookResult) => {
const getScene = () => {
if (deleteMutation.error) {
if (isNoTrustchainError(deleteMutation.error)) {
return <SpecificError error={ErrorReason.NO_TRUSTCHAIN} primaryAction={onCreateKey} />;
}
return (
<GenericErrorView
error={deleteMutation.error}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useNavigation } from "@react-navigation/native";
import { useCallback } from "react";
import { StackNavigatorNavigation } from "~/components/RootNavigator/types/helpers";
import { WalletSyncNavigatorStackParamList } from "~/components/RootNavigator/types/WalletSyncNavigator";
import { ScreenName } from "~/const";
import { NavigatorName, ScreenName } from "~/const";
import { logDrawer } from "LLM/components/QueuedDrawer/utils/logDrawer";
import { useDestroyTrustchain } from "../../hooks/useDestroyTrustchain";
import { UseMutationResult } from "@tanstack/react-query";
Expand All @@ -11,6 +11,7 @@ import { setWallectSyncManageKeyDrawer } from "~/actions/walletSync";
import { manageKeyDrawerSelector } from "~/reducers/walletSync";
import { track } from "~/analytics";
import { AnalyticsButton, AnalyticsPage } from "../../hooks/useLedgerSyncAnalytics";
import { NavigationProps } from "~/screens/AccountSettings";

const messageLog = "Follow Steps on device";

Expand All @@ -22,6 +23,7 @@ export type HookResult = {
onClickConfirm: () => Promise<void>;
deleteMutation: UseMutationResult<void, Error, void, unknown>;
handleCancel: () => void;
onCreateKey: () => void;
};

export const useManageKeyDrawer = () => {
Expand All @@ -43,6 +45,7 @@ export const useManageKeyDrawer = () => {
}, [dispatch]);

const navigation = useNavigation<StackNavigatorNavigation<WalletSyncNavigatorStackParamList>>();
const baseNavigation = useNavigation<NavigationProps["navigation"]>();

const handleClose = () => {
closeDrawer();
Expand Down Expand Up @@ -72,6 +75,12 @@ export const useManageKeyDrawer = () => {
navigation.navigate(ScreenName.WalletSyncManageKeyDeleteSuccess);
};

const onCreateKey = () => {
baseNavigation.navigate(NavigatorName.WalletSync, {
screen: ScreenName.WalletSyncActivationProcess,
});
};

return {
isDrawerVisible,
openDrawer,
Expand All @@ -80,5 +89,6 @@ export const useManageKeyDrawer = () => {
deleteMutation,
handleCancel,
handleClose,
onCreateKey,
};
};
Loading