From 882e7ad904c2065b0e5dc54c8d8a28ee7964f5f6 Mon Sep 17 00:00:00 2001 From: Olivier Freyssinet Date: Mon, 9 Sep 2024 16:53:09 +0200 Subject: [PATCH] refactor: remove feature flag "deviceSupportEuropa" (for Ledger Flex) --- .changeset/soft-cherries-fold.md | 8 ++++ .../CustomImage/DeviceModelPicker.tsx | 17 ++----- .../Screens/SelectDevice/DeviceSelector.tsx | 46 ++++++------------- .../Developer/FeatureFlagsSettings/index.tsx | 38 ++------------- .../tests/userdata/speculos-tests-app.json | 8 ---- .../screens/CustomImage/PreviewPreEdit.tsx | 13 +----- .../Onboarding/steps/deviceSelection.tsx | 23 ++++------ .../src/screens/Settings/Debug/index.tsx | 35 -------------- .../src/featureFlags/defaultFeatures.ts | 1 - .../src/featureFlags/groupedFeatures.ts | 5 +- .../packages/types-live/src/feature.ts | 2 - 11 files changed, 40 insertions(+), 156 deletions(-) create mode 100644 .changeset/soft-cherries-fold.md diff --git a/.changeset/soft-cherries-fold.md b/.changeset/soft-cherries-fold.md new file mode 100644 index 000000000000..34e7b17b7fec --- /dev/null +++ b/.changeset/soft-cherries-fold.md @@ -0,0 +1,8 @@ +--- +"@ledgerhq/types-live": patch +"ledger-live-desktop": patch +"live-mobile": patch +"@ledgerhq/live-common": patch +--- + +Remove feature flag "deviceSupportEuropa" (for Ledger Flex) diff --git a/apps/ledger-live-desktop/src/renderer/components/CustomImage/DeviceModelPicker.tsx b/apps/ledger-live-desktop/src/renderer/components/CustomImage/DeviceModelPicker.tsx index 022f2fbe906a..5fa10d193823 100644 --- a/apps/ledger-live-desktop/src/renderer/components/CustomImage/DeviceModelPicker.tsx +++ b/apps/ledger-live-desktop/src/renderer/components/CustomImage/DeviceModelPicker.tsx @@ -5,8 +5,6 @@ import { supportedDeviceModelIds, } from "@ledgerhq/live-common/device/use-cases/isCustomLockScreenSupported"; import { Bar, Flex, Text } from "@ledgerhq/react-ui"; -import { DeviceModelId } from "@ledgerhq/types-devices"; -import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; type Props = { deviceModelId: CLSSupportedDeviceModelId; @@ -14,24 +12,15 @@ type Props = { }; export default function DeviceModelPicker({ deviceModelId, onChange }: Props) { - const supportDeviceEuropa = useFeature("supportDeviceEuropa")?.enabled; - const supportedAndEnabledDeviceModelIds = supportedDeviceModelIds.filter(() => { - const devicesSupported: Record = { - [DeviceModelId.stax]: true, - [DeviceModelId.europa]: Boolean(supportDeviceEuropa), - }; - return devicesSupported[deviceModelId]; - }, [supportDeviceEuropa]); - return ( { - onChange(supportedAndEnabledDeviceModelIds[i]); + onChange(supportedDeviceModelIds[i]); }} > - {supportedAndEnabledDeviceModelIds.map(deviceModelId => ( + {supportedDeviceModelIds.map(deviceModelId => ( void; } export function DeviceSelector({ onClick }: DeviceSelectorProps) { - const deviceEuropaSupported = useFeature("supportDeviceEuropa"); - - const devices = useMemo( - () => [ - { id: DeviceModelId.stax, enabled: true }, - ...(deviceEuropaSupported?.enabled ? [{ id: DeviceModelId.europa, enabled: true }] : []), - ...allDevices, - ], - [deviceEuropaSupported], - ); - return ( - {devices.map(({ id, enabled }, index, arr) => ( + {allDevicesModelIds.map((deviceModelId, index, arr) => ( } - onClick={() => enabled && onClick(id as DeviceModelId)} + id={`device-${deviceModelId}`} + key={deviceModelId} + label={getDeviceModel(deviceModelId).productName} + Illu={} + onClick={() => onClick(deviceModelId as DeviceModelId)} isFirst={index === 0} isLast={index === arr.length - 1} /> diff --git a/apps/ledger-live-desktop/src/renderer/screens/settings/sections/Developer/FeatureFlagsSettings/index.tsx b/apps/ledger-live-desktop/src/renderer/screens/settings/sections/Developer/FeatureFlagsSettings/index.tsx index 80680b67e30e..484ff15f7293 100644 --- a/apps/ledger-live-desktop/src/renderer/screens/settings/sections/Developer/FeatureFlagsSettings/index.tsx +++ b/apps/ledger-live-desktop/src/renderer/screens/settings/sections/Developer/FeatureFlagsSettings/index.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState, useMemo, useCallback, useRef } from "react"; +import React, { useEffect, useState, useMemo, useCallback } from "react"; import { useDispatch, useSelector } from "react-redux"; import ButtonV2 from "~/renderer/components/Button"; import Button from "~/renderer/components/ButtonV3"; @@ -29,7 +29,7 @@ export const FeatureFlagContent = withV3StyleProvider((props: { expanded?: boole const { t } = useTranslation(); const featureFlagsButtonVisible = useSelector(featureFlagsButtonVisibleSelector); const dispatch = useDispatch(); - const { getFeature, overrideFeature, isFeature, resetFeatures } = useFeatureFlags(); + const { isFeature, resetFeatures } = useFeatureFlags(); const [focusedName, setFocusedName] = useState(); const [searchInput, setSearchInput] = useState(""); const [activeTabIndex, setActiveTabIndex] = useState(0); @@ -69,35 +69,6 @@ export const FeatureFlagContent = withV3StyleProvider((props: { expanded?: boole ); }, [searchInput]); - const timeoutRef = useRef | null>(null); - const pressCount = useRef(0); - - const [cheatActivated, setCheatActivated] = useState(false); - const ruleThemAll = useCallback(() => { - groupedFeatures.europa.featureIds.forEach(featureId => - overrideFeature(featureId, { ...getFeature(featureId), enabled: true }), - ); - setCheatActivated(true); - }, [getFeature, overrideFeature]); - - const onDescriptionClick = useCallback(() => { - if (timeoutRef.current) { - clearTimeout(timeoutRef.current); - } - pressCount.current += 1; - const timeout = setTimeout(() => { - pressCount.current = 0; - }, 300); - if (pressCount.current > 6) { - ruleThemAll(); - pressCount.current = 0; - } - timeoutRef.current = timeout; - return () => { - clearTimeout(timeout); - }; - }, [ruleThemAll]); - const flagsList = useMemo( () => filteredFlags.map(flagName => ( @@ -143,10 +114,7 @@ export const FeatureFlagContent = withV3StyleProvider((props: { expanded?: boole return ( -
- {t("settings.developer.featureFlagsDesc")} - {cheatActivated ? " With great power comes great responsibility." : null} -
+
{t("settings.developer.featureFlagsDesc")}
{!props.expanded ? null : ( <> diff --git a/apps/ledger-live-desktop/tests/userdata/speculos-tests-app.json b/apps/ledger-live-desktop/tests/userdata/speculos-tests-app.json index a4495588bf2a..cf4310f8a55a 100644 --- a/apps/ledger-live-desktop/tests/userdata/speculos-tests-app.json +++ b/apps/ledger-live-desktop/tests/userdata/speculos-tests-app.json @@ -101,14 +101,6 @@ "llmNewFirmwareUpdateUx": { "enabled": true, "overridesRemote": true - }, - "supportDeviceEuropa": { - "enabled": true, - "overridesRemote": true - }, - "supportDeviceStax": { - "enabled": true, - "overridesRemote": true } }, "featureFlagsButtonVisible": false, diff --git a/apps/ledger-live-mobile/src/screens/CustomImage/PreviewPreEdit.tsx b/apps/ledger-live-mobile/src/screens/CustomImage/PreviewPreEdit.tsx index ede64a9b765d..e0ae32d8e3c7 100644 --- a/apps/ledger-live-mobile/src/screens/CustomImage/PreviewPreEdit.tsx +++ b/apps/ledger-live-mobile/src/screens/CustomImage/PreviewPreEdit.tsx @@ -25,7 +25,6 @@ import { CLSSupportedDeviceModelId, supportedDeviceModelIds, } from "@ledgerhq/live-common/device/use-cases/isCustomLockScreenSupported"; -import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; import { BaseComposite, StackNavigatorProps } from "~/components/RootNavigator/types/helpers"; import { CustomImageNavigatorParamList } from "~/components/RootNavigator/types/CustomImageNavigator"; @@ -111,14 +110,6 @@ const PreviewPreEdit = ({ navigation, route }: NavigationProps) => { params.deviceModelId ?? DeviceModelId.stax, ); - const supportDeviceEuropa = useFeature("supportDeviceEuropa")?.enabled; - const supportedAndEnabledDeviceModelIds = supportedDeviceModelIds.filter(() => { - const devicesSupported: Record = { - [DeviceModelId.stax]: true, - [DeviceModelId.europa]: Boolean(supportDeviceEuropa), - }; - return devicesSupported[deviceModelId]; - }, [supportDeviceEuropa]); const targetDisplayDimensions = useMemo( () => getScreenVisibleAreaDimensions(deviceModelId), [deviceModelId], @@ -373,9 +364,9 @@ const PreviewPreEdit = ({ navigation, route }: NavigationProps) => { return ( - {!params.deviceModelId && supportDeviceEuropa && ( + {!params.deviceModelId && ( - {supportedAndEnabledDeviceModelIds.map(modelId => ( + {supportedDeviceModelIds.map(modelId => ( onChangeDeviceModelId(modelId)} diff --git a/apps/ledger-live-mobile/src/screens/Onboarding/steps/deviceSelection.tsx b/apps/ledger-live-mobile/src/screens/Onboarding/steps/deviceSelection.tsx index 71776647ef4b..41f5da465d5f 100644 --- a/apps/ledger-live-mobile/src/screens/Onboarding/steps/deviceSelection.tsx +++ b/apps/ledger-live-mobile/src/screens/Onboarding/steps/deviceSelection.tsx @@ -1,8 +1,7 @@ import { getDeviceModel } from "@ledgerhq/devices/index"; -import useFeature from "@ledgerhq/live-common/featureFlags/useFeature"; import { DeviceModelId } from "@ledgerhq/types-devices"; import { useNavigation } from "@react-navigation/native"; -import React, { useMemo, useState } from "react"; +import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { Platform } from "react-native"; import { isSyncOnboardingSupported } from "@ledgerhq/live-common/device/use-cases/isSyncOnboardingSupported"; @@ -53,24 +52,20 @@ export const devices = { const NOT_SUPPORTED_DEVICES_IOS = [DeviceModelId.nanoS, DeviceModelId.nanoSP]; +const availableDevices = [ + devices.stax, + devices.europa, + devices.nanoX, + devices.nanoSP, + devices.nanoS, +]; + function OnboardingStepDeviceSelection() { const navigation = useNavigation(); const { t } = useTranslation(); - const deviceEuropaSupported = useFeature("supportDeviceEuropa"); const [isOpen, setOpen] = useState(false); - const availableDevices = useMemo( - () => [ - devices.stax, - ...(deviceEuropaSupported?.enabled ? [devices.europa] : []), - devices.nanoX, - devices.nanoSP, - devices.nanoS, - ], - [deviceEuropaSupported], - ); - const getProductName = (modelId: DeviceModelId) => getDeviceModel(modelId)?.productName.replace("Ledger", "").trimStart() || modelId; diff --git a/apps/ledger-live-mobile/src/screens/Settings/Debug/index.tsx b/apps/ledger-live-mobile/src/screens/Settings/Debug/index.tsx index 2695c89f0d25..3a01684db8f2 100644 --- a/apps/ledger-live-mobile/src/screens/Settings/Debug/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Settings/Debug/index.tsx @@ -14,36 +14,6 @@ import PoweredByLedger from "../PoweredByLedger"; export default function DebugSettings({ navigation: { navigate }, }: StackNavigatorProps) { - const timeoutRef = useRef | null>(null); - const pressCount = useRef(0); - - const { getFeature, overrideFeature } = useFeatureFlags(); - - const ruleThemAll = useCallback(() => { - groupedFeatures.europa.featureIds.forEach(featureId => - overrideFeature(featureId, { ...getFeature(featureId), enabled: true }), - ); - Alert.alert("I can only show you the door, you're the one that has to walk through it."); - }, [overrideFeature, getFeature]); - - const onDebugHiddenPress = useCallback(() => { - if (timeoutRef.current) { - clearTimeout(timeoutRef.current); - } - pressCount.current += 1; - const timeout = setTimeout(() => { - pressCount.current = 0; - }, 300); - if (pressCount.current > 6) { - ruleThemAll(); - pressCount.current = 0; - } - timeoutRef.current = timeout; - return () => { - clearTimeout(timeout); - }; - }, [ruleThemAll]); - return ( @@ -99,11 +69,6 @@ export default function DebugSettings({ iconLeft={} onPress={() => navigate(ScreenName.DebugPlayground)} /> - - - - - ); } diff --git a/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts b/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts index b5542ad71e25..294e9b074d64 100644 --- a/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts +++ b/libs/ledger-live-common/src/featureFlags/defaultFeatures.ts @@ -460,7 +460,6 @@ export const DEFAULT_FEATURES: Features = { lldChatbotSupport: DEFAULT_FEATURE, llmChatbotSupport: DEFAULT_FEATURE, - supportDeviceEuropa: DEFAULT_FEATURE, lldRefreshMarketData: { ...DEFAULT_FEATURE, params: { diff --git a/libs/ledger-live-common/src/featureFlags/groupedFeatures.ts b/libs/ledger-live-common/src/featureFlags/groupedFeatures.ts index 236084211801..8129ce6ad2a8 100644 --- a/libs/ledger-live-common/src/featureFlags/groupedFeatures.ts +++ b/libs/ledger-live-common/src/featureFlags/groupedFeatures.ts @@ -1,6 +1,6 @@ import { FeatureId } from "@ledgerhq/types-live"; -export type GroupedFeature = "europa" | "disableNft"; +export type GroupedFeature = "disableNft"; /** Helper to group several feature flag ids under a common feature flag */ export const groupedFeatures: Record< @@ -9,9 +9,6 @@ export const groupedFeatures: Record< featureIds: FeatureId[]; } > = { - europa: { - featureIds: ["supportDeviceEuropa", "deviceInitialApps"], - }, disableNft: { featureIds: ["disableNftLedgerMarket", "disableNftRaribleOpensea", "disableNftSend"], }, diff --git a/libs/ledgerjs/packages/types-live/src/feature.ts b/libs/ledgerjs/packages/types-live/src/feature.ts index 467097adba3f..a4b9922c57c4 100644 --- a/libs/ledgerjs/packages/types-live/src/feature.ts +++ b/libs/ledgerjs/packages/types-live/src/feature.ts @@ -179,7 +179,6 @@ export type Features = CurrencyFeatures & { nftsFromSimplehash: Feature_NftsFromSimpleHash; lldActionCarousel: Feature_lldActionCarousel; marketperformanceWidgetDesktop: Feature_MarketperformanceWidgetDesktop; - supportDeviceEuropa: Feature_SupportDeviceEuropa; lldRefreshMarketData: Feature_LldRefreshMarketData; llmRefreshMarketData: Feature_LlmRefreshMarketData; spamReportNfts: Feature_SpamReportNfts; @@ -504,7 +503,6 @@ export type Feature_PtxSwapThorswapProvider = DefaultFeature; export type Feature_PtxSwapReceiveTRC20WithoutTrx = DefaultFeature; export type Feature_FlexibleContentCards = DefaultFeature; export type Feature_MyLedgerDisplayAppDeveloperName = DefaultFeature; -export type Feature_SupportDeviceEuropa = DefaultFeature; export type Feature_LldChatbotSupport = DefaultFeature; export type Feature_LlmChatbotSupport = DefaultFeature; export type Feature_SpamReportNfts = DefaultFeature;