-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗝️ [FIX]: llm "Delete my encryption key" action on wrong seed errors (#…
…7668) * Fix the "Delete my encription key" action on sync error * Update changelog --------- Co-authored-by: Theophile Sandoz <Theophile Sandoz>
- Loading branch information
Showing
7 changed files
with
131 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"live-mobile": minor | ||
--- | ||
|
||
Fix "Delete my encryption key" action on wrong seed errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
apps/ledger-live-mobile/src/newArch/features/WalletSync/hooks/useFollowInstructionDrawer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useNavigation } from "@react-navigation/native"; | ||
import { Dispatch, SetStateAction, useCallback, useState } from "react"; | ||
import { Device } from "@ledgerhq/live-common/hw/actions/types"; | ||
import { StackNavigatorNavigation } from "~/components/RootNavigator/types/helpers"; | ||
import { WalletSyncNavigatorStackParamList } from "~/components/RootNavigator/types/WalletSyncNavigator"; | ||
import { ScreenName } from "~/const"; | ||
import { useDestroyTrustchain } from "./useDestroyTrustchain"; | ||
|
||
export enum SceneKind { | ||
DeviceInstructions, | ||
Loader, | ||
WrongSeedError, | ||
KeyError, | ||
GenericError, | ||
} | ||
type Scene = | ||
| { kind: SceneKind.DeviceInstructions; device: Device } | ||
| { kind: SceneKind.Loader } | ||
| { kind: SceneKind.WrongSeedError } | ||
| { kind: SceneKind.KeyError } | ||
| { kind: SceneKind.GenericError; error: Error }; | ||
|
||
export type DrawerProps = { | ||
scene: Scene; | ||
onRetry: () => void; | ||
goToDelete: () => void; | ||
backToKeyError: () => void; | ||
confirmDeleteKey: () => void; | ||
}; | ||
|
||
export function useFollowInstructionDrawer(): [DrawerProps, Dispatch<SetStateAction<Scene>>] { | ||
const navigation = useNavigation<StackNavigatorNavigation<WalletSyncNavigatorStackParamList>>(); | ||
const { deleteMutation } = useDestroyTrustchain(); | ||
|
||
const [scene, setScene] = useState<Scene>({ kind: SceneKind.Loader }); | ||
|
||
// eslint-disable-next-line no-console | ||
const onRetry = useCallback(() => console.log("onRetry"), []); | ||
|
||
const goToDelete = useCallback(() => { | ||
setScene({ kind: SceneKind.WrongSeedError }); | ||
}, []); | ||
|
||
const backToKeyError = useCallback(() => { | ||
setScene({ kind: SceneKind.KeyError }); | ||
}, []); | ||
|
||
const confirmDeleteKey = useCallback(async () => { | ||
await deleteMutation.mutateAsync(); | ||
navigation.navigate(ScreenName.WalletSyncManageKeyDeleteSuccess); | ||
}, [deleteMutation, navigation]); | ||
|
||
return [{ scene, onRetry, goToDelete, backToKeyError, confirmDeleteKey }, setScene]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters