diff --git a/.changeset/perfect-dingos-play.md b/.changeset/perfect-dingos-play.md new file mode 100644 index 000000000000..4105cb014d5a --- /dev/null +++ b/.changeset/perfect-dingos-play.md @@ -0,0 +1,6 @@ +--- +"@ledgerhq/types-devices": patch +"live-mobile": patch +--- + +Fix scanning QR code cannot show all devices with grand screen issue. diff --git a/apps/ledger-live-mobile/src/components/BleDevicePairingFlow/BleDevicesScanning.tsx b/apps/ledger-live-mobile/src/components/BleDevicePairingFlow/BleDevicesScanning.tsx index 1c521b8eb105..5488a94f87b5 100644 --- a/apps/ledger-live-mobile/src/components/BleDevicePairingFlow/BleDevicesScanning.tsx +++ b/apps/ledger-live-mobile/src/components/BleDevicePairingFlow/BleDevicesScanning.tsx @@ -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"; @@ -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(false); const [locationUnauthorizedError, setLocationUnauthorizedError] = useState(false); @@ -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, diff --git a/libs/ledgerjs/packages/types-devices/README.md b/libs/ledgerjs/packages/types-devices/README.md index 97d09120df5b..a1661854b154 100644 --- a/libs/ledgerjs/packages/types-devices/README.md +++ b/libs/ledgerjs/packages/types-devices/README.md @@ -11,6 +11,7 @@ Ledger types for devices and transport. #### Table of Contents * [DeviceModelId](#devicemodelid) +* [QRCodeDevices](#qrcodedevices) * [DeviceModel](#devicemodel) * [ChargingModes](#chargingmodes) * [BatteryStatusFlags](#batterystatusflags) @@ -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. diff --git a/libs/ledgerjs/packages/types-devices/src/index.ts b/libs/ledgerjs/packages/types-devices/src/index.ts index 03ad0f726a28..ef7ab3b876df 100644 --- a/libs/ledgerjs/packages/types-devices/src/index.ts +++ b/libs/ledgerjs/packages/types-devices/src/index.ts @@ -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. */