Skip to content

Commit

Permalink
Merge pull request #7204 from LedgerHQ/bugfix/live-13090
Browse files Browse the repository at this point in the history
[LIVE-13090][LLM][Flex] User is redirected to the Stax bluetooth pairing flow when he scans QR Code from Flex
  • Loading branch information
jiyuzhuang authored Jun 28, 2024
2 parents 62701c5 + c9329bb commit 80871b5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/perfect-dingos-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@ledgerhq/types-devices": patch
"live-mobile": patch
---

Fix scanning QR code cannot show all devices with grand screen issue.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { HwTransportErrorType } from "@ledgerhq/errors";
import { useTranslation } from "react-i18next";
import { useSelector } from "react-redux";
import { getDeviceModel } from "@ledgerhq/devices";
import { Device, DeviceModelId } from "@ledgerhq/types-devices";
import { Device, DeviceModelId, QRCodeDevices } from "@ledgerhq/types-devices";
import { IconsLegacy } from "@ledgerhq/native-ui";
import TransportBLE from "../../react-native-hw-transport-ble";
import { knownDevicesSelector } from "~/reducers/ble";
Expand Down Expand Up @@ -50,9 +50,13 @@ export default function BleDevicesScanning({
}: BleDevicesScanningProps) {
const { t } = useTranslation();

const productName = filterByDeviceModelId
? getDeviceModel(filterByDeviceModelId).productName || filterByDeviceModelId
: null;
const isQRCodeDevice =
filterByDeviceModelId !== null && QRCodeDevices.includes(filterByDeviceModelId);

const productName =
filterByDeviceModelId && !isQRCodeDevice
? getDeviceModel(filterByDeviceModelId).productName || filterByDeviceModelId
: null;

const [locationDisabledError, setLocationDisabledError] = useState<boolean>(false);
const [locationUnauthorizedError, setLocationUnauthorizedError] = useState<boolean>(false);
Expand Down Expand Up @@ -98,10 +102,12 @@ export default function BleDevicesScanning({
[areKnownDevicesDisplayed, knownDeviceIds],
);

const filterByDeviceModelIds = useMemo(
() => (filterByDeviceModelId ? [filterByDeviceModelId] : undefined),
[filterByDeviceModelId],
);
const filterByDeviceModelIds = useMemo(() => {
if (isQRCodeDevice) {
return QRCodeDevices;
}
return filterByDeviceModelId ? [filterByDeviceModelId] : undefined;
}, [filterByDeviceModelId, isQRCodeDevice]);

const { scannedDevices, scanningBleError } = useBleDevicesScanning({
bleTransportListen: TransportBLE.listen,
Expand Down
7 changes: 7 additions & 0 deletions libs/ledgerjs/packages/types-devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Ledger types for devices and transport.
#### Table of Contents

* [DeviceModelId](#devicemodelid)
* [QRCodeDevices](#qrcodedevices)
* [DeviceModel](#devicemodel)
* [ChargingModes](#chargingmodes)
* [BatteryStatusFlags](#batterystatusflags)
Expand All @@ -30,6 +31,12 @@ Ledger types for devices and transport.

DeviceModelId is a unique identifier to identify the model of a Ledger hardware wallet.

### QRCodeDevices

QRCodeDevices is a list of DeviceModelId of whom the Ledger device can present a QR code.

Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[DeviceModelId](#devicemodelid)>

### DeviceModel

a DeviceModel contains all the information of a specific Ledger hardware wallet model.
Expand Down
6 changes: 6 additions & 0 deletions libs/ledgerjs/packages/types-devices/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export enum DeviceModelId {
stax = "stax",
europa = "europa",
}

/**
* QRCodeDevices is a list of DeviceModelId of whom the Ledger device can present a QR code.
*/
export const QRCodeDevices: DeviceModelId[] = [DeviceModelId.stax, DeviceModelId.europa];

/**
* a DeviceModel contains all the information of a specific Ledger hardware wallet model.
*/
Expand Down

0 comments on commit 80871b5

Please sign in to comment.