Skip to content

Commit

Permalink
bugfix(onboarding): stax with lnx plugged
Browse files Browse the repository at this point in the history
  • Loading branch information
jdabbech-ledger committed Oct 25, 2023
1 parent 954b230 commit 65191b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-cooks-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

fix an infinite loop on select stax with lnx plugged during onboarding
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useContext } from "react";
import React, { useCallback, useContext, useEffect } from "react";
import { Flex, Link, Text } from "@ledgerhq/react-ui";
import { useTranslation } from "react-i18next";
import { DeviceModelId, getDeviceModel } from "@ledgerhq/devices";
Expand All @@ -8,6 +8,8 @@ import { OnboardingContext } from "../../Onboarding";
import { getDeviceAnimation } from "~/renderer/components/DeviceAction/animations";
import Animation from "~/renderer/animations";
import useTheme from "~/renderer/hooks/useTheme";
import { useSelector } from "react-redux";
import { getCurrentDevice } from "~/renderer/reducers/devices";

export type SyncOnboardingDeviceConnectionSearchingProps = {
deviceModelId: DeviceModelId;
Expand All @@ -21,6 +23,14 @@ const SyncOnboardingDeviceConnectionSearching = ({
const history = useHistory();
const { setDeviceModelId } = useContext(OnboardingContext);
const theme = useTheme();
const currentDevice = useSelector(getCurrentDevice);

useEffect(() => {
if (currentDevice && currentDevice.modelId !== deviceModelId) {
setDeviceModelId(currentDevice.modelId);
history.replace("/onboarding/select-use-case");
}
}, [currentDevice, deviceModelId, history, setDeviceModelId]);

const handleConnectionTrouble = useCallback(() => {
setDeviceModelId(deviceModelId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const SyncOnboardingDeviceConnection = ({

const deviceModelId = stringToDeviceModelId(strDeviceModelId, DeviceModelId.stax);

if (currentDevice) {
if (currentDevice && currentDevice.modelId === deviceModelId) {
setTimeout(
() =>
// Uses the modelId from the newly connected device, in case the route prop strDeviceModelId is different
Expand Down

0 comments on commit 65191b7

Please sign in to comment.