Skip to content

Commit

Permalink
FAT-659 Automatically select last seen device if compatible for CLS (#…
Browse files Browse the repository at this point in the history
…1911)

* FAT-659 Automatically select last seen device if compatible for CLS

* FAT-659 Add changelog
  • Loading branch information
grsoares21 authored Nov 30, 2022
1 parent b7107fa commit 5000d82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-fishes-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Auto-select the last connected device for CLS if it is a Nano FTS
13 changes: 11 additions & 2 deletions apps/ledger-live-mobile/src/screens/CustomImage/Step3Transfer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useState } from "react";
import React, { useCallback, useEffect, useState } from "react";
import { ScrollView } from "react-native";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { Flex } from "@ledgerhq/native-ui";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Device } from "@ledgerhq/live-common/hw/actions/types";
Expand All @@ -17,6 +17,7 @@ import {
StackNavigatorProps,
} from "../../components/RootNavigator/types/helpers";
import { CustomImageNavigatorParamList } from "../../components/RootNavigator/types/CustomImageNavigator";
import { lastConnectedDeviceSelector } from "../../reducers/settings";

const deviceModelIds = [DeviceModelId.nanoFTS];

Expand All @@ -43,7 +44,15 @@ type NavigationProps = BaseComposite<
const Step3Transfer = ({ route, navigation }: NavigationProps) => {
const dispatch = useDispatch();
const { rawData, device: deviceFromRoute, previewData } = route.params;

const [device, setDevice] = useState<Device | null>(deviceFromRoute);
const lastConnectedDevice = useSelector(lastConnectedDeviceSelector);

useEffect(() => {
if (!device && lastConnectedDevice?.modelId === DeviceModelId.nanoFTS) {
setDevice(lastConnectedDevice);
}
}, [lastConnectedDevice, device]);

const handleError = useCallback(
(error: Error) => {
Expand Down

0 comments on commit 5000d82

Please sign in to comment.