Skip to content

Commit

Permalink
fix(suite-native): correct error for firmwareless device (#10635)
Browse files Browse the repository at this point in the history
* fix(suite-native): correct error for firmwareless device

This commit fixes the error message for firmwareless devices. Until now if you have connected firmwareless device, the error message saying that the device is in bootloader mode was displayed. After this change, correct message instructing user to setup the device is displayed.

Closes #10611
  • Loading branch information
PeKne authored Jan 12, 2024
1 parent e089477 commit be06d91
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions suite-common/wallet-core/src/device/deviceReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,3 +723,9 @@ export const selectDeviceLanguage = (state: DeviceRootState) => {
const features = selectDeviceFeatures(state);
return features?.language ?? null;
};

export const selectHasDeviceFirmwareInstalled = (state: DeviceRootState) => {
const device = selectDevice(state);

return !!device && device.firmware !== 'none';
};
13 changes: 11 additions & 2 deletions suite-native/device/src/hooks/useDetectDeviceError.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
selectIsDeviceInBootloader,
selectIsUnacquiredDevice,
selectIsSelectedDeviceImported,
selectHasDeviceFirmwareInstalled,
} from '@suite-common/wallet-core';
import { useAlert } from '@suite-native/alerts';
import { useTranslate } from '@suite-native/intl';
Expand All @@ -33,6 +34,7 @@ export const useDetectDeviceError = () => {
const isSelectedDeviceImported = useSelector(selectIsSelectedDeviceImported);
const isNoPhysicalDeviceConnected = useSelector(selectIsNoPhysicalDeviceConnected);
const isDeviceInBootloader = useSelector(selectIsDeviceInBootloader);
const hasDeviceFirmwareInstalled = useSelector(selectHasDeviceFirmwareInstalled);

const isFirmwareSupported = useSelector(selectIsFirmwareSupported);

Expand Down Expand Up @@ -127,7 +129,7 @@ export const useDetectDeviceError = () => {
]);

useEffect(() => {
if (isDeviceInBootloader && !wasDeviceEjectedByUser) {
if (isDeviceInBootloader && hasDeviceFirmwareInstalled && !wasDeviceEjectedByUser) {
showAlert({
title: translate('moduleDevice.bootloaderModal.title'),
description: translate('moduleDevice.bootloaderModal.description'),
Expand All @@ -145,7 +147,14 @@ export const useDetectDeviceError = () => {
},
});
}
}, [isDeviceInBootloader, wasDeviceEjectedByUser, showAlert, translate, handleDisconnect]);
}, [
isDeviceInBootloader,
hasDeviceFirmwareInstalled,
wasDeviceEjectedByUser,
showAlert,
translate,
handleDisconnect,
]);

useEffect(() => {
// Hide the error alert on disconnect of the device
Expand Down

0 comments on commit be06d91

Please sign in to comment.