diff --git a/src/app/pages/OpenWalletPage/Features/FromLedger/index.tsx b/src/app/pages/OpenWalletPage/Features/FromLedger/index.tsx index f846557690..34b7170381 100644 --- a/src/app/pages/OpenWalletPage/Features/FromLedger/index.tsx +++ b/src/app/pages/OpenWalletPage/Features/FromLedger/index.tsx @@ -6,6 +6,7 @@ import { Button } from 'grommet/es6/components/Button' import { Text } from 'grommet/es6/components/Text' import { canAccessBle, canAccessNavigatorUsb } from '../../../../lib/ledger' import { useTranslation } from 'react-i18next' +import { useNavigate } from 'react-router-dom' type SelectOpenMethodProps = { webExtensionLedgerAccess?: () => void @@ -15,15 +16,25 @@ export function FromLedger({ webExtensionLedgerAccess }: SelectOpenMethodProps) const { t } = useTranslation() const [supportsUsbLedger, setSupportsUsbLedger] = React.useState(true) const [supportsBleLedger, setSupportsBleLedger] = React.useState(true) + const navigate = useNavigate() useEffect(() => { async function getLedgerSupport() { - setSupportsUsbLedger(await canAccessNavigatorUsb()) - setSupportsBleLedger(await canAccessBle()) + const usbLedgerSupported = await canAccessNavigatorUsb() + const bleLedgerSupported = await canAccessBle() + + if (usbLedgerSupported && !bleLedgerSupported) { + navigate('usb') + } else if (bleLedgerSupported && !usbLedgerSupported) { + navigate('ble') + } + + setSupportsUsbLedger(usbLedgerSupported) + setSupportsBleLedger(bleLedgerSupported) } getLedgerSupport() - }, []) + }, [navigate]) return (