Skip to content

Commit

Permalink
fix(suite-native): fix device onboarding feature flag evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
PeKne committed Feb 12, 2025
1 parent e699505 commit 26bea22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
5 changes: 3 additions & 2 deletions suite-native/device/src/hooks/useHandleDeviceConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ export const useHandleDeviceConnection = () => {
if (isFirmwareInstallationRunning || isSuspiciousDeviceScreenFocused(navigation)) return;

if (
isDeviceInitialized &&
isDeviceConnected &&
isOnboardingFinished &&
!isPortfolioTrackerDevice &&
!isDeviceConnectedAndAuthorized &&
!isBiometricsOverlayVisible &&
!shouldNavigateToDeviceCompromisedModal
!shouldNavigateToDeviceCompromisedModal &&
!isDeviceSetupSupported
) {
requestPrioritizedDeviceAccess({
deviceCallback: () => dispatch(authorizeDeviceThunk()),
Expand Down Expand Up @@ -165,6 +165,7 @@ export const useHandleDeviceConnection = () => {
isFirmwareInstallationRunning,
isDeviceInitialized,
shouldNavigateToDeviceCompromisedModal,
isDeviceSetupSupported,
]);

// In case that the physical device is disconnected, redirect to the home screen and
Expand Down
16 changes: 12 additions & 4 deletions suite-native/device/src/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { A, pipe } from '@mobily/ts-belt';
import { A, G, pipe } from '@mobily/ts-belt';

import {
Feature,
Expand Down Expand Up @@ -47,7 +47,8 @@ type NativeDeviceRootState = DeviceRootState &
AccountsRootState &
DiscoveryRootState &
SettingsSliceRootState &
FiatRatesRootState;
FiatRatesRootState &
FeatureFlagsRootState;

const createMemoizedSelector = createWeakMapSelector.withTypes<NativeDeviceRootState>();

Expand Down Expand Up @@ -199,6 +200,13 @@ export const selectHasFirmwareAuthenticityCheckHardFailed = (state: FwAuthentici
};

export const selectIsDeviceSetupSupported = createMemoizedSelector(
[selectDeviceModel],
model => !!model && isDeviceSetupSupported(model),
[
selectDeviceModel,
(state: NativeDeviceRootState) =>
selectIsFeatureFlagEnabled(state, FeatureFlag.IsDeviceOnboardingEnabled),
],
(model, isDeviceOnboardingFeatureFlagEnabled) =>
isDeviceOnboardingFeatureFlagEnabled &&
G.isNotNullable(model) &&
isDeviceSetupSupported(model),
);

0 comments on commit 26bea22

Please sign in to comment.