From 61db1cc709251b3f0781e54ff4e7c99427412489 Mon Sep 17 00:00:00 2001 From: Olivier Freyssinet Date: Thu, 24 Feb 2022 14:20:05 +0100 Subject: [PATCH] Add experimental dev toggle for using learn staging URL --- package.json | 2 +- src/experimental.js | 6 ++++++ src/screens/Learn/index.tsx | 11 +++++++++-- yarn.lock | 5 ++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 8277fe35d9..eb2d3df4ba 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "@ledgerhq/errors": "6.10.0", "@ledgerhq/hw-transport": "6.24.1", "@ledgerhq/hw-transport-http": "6.24.1", - "@ledgerhq/live-common": "^21.33.0", + "@ledgerhq/live-common": "https://github.com/LedgerHQ/ledger-live-common.git#c14a6b5c83cfffe0a7e1e3de50f64f96bfc7449a", "@ledgerhq/logs": "6.10.0", "@ledgerhq/native-ui": "^0.7.0", "@ledgerhq/react-native-hid": "6.24.1", diff --git a/src/experimental.js b/src/experimental.js index 132a663cdf..52ab7556b0 100644 --- a/src/experimental.js +++ b/src/experimental.js @@ -107,6 +107,12 @@ export const developerFeatures: Feature[] = [ title: "Allow experimental apps", description: "Display and allow opening experimental tagged platform apps.", }, + { + type: "toggle", + name: "USE_LEARN_STAGING_URL", + title: "Learn staging URL", + description: "Use the staging URL for the Learn page.", + }, ]; const storageKey = "experimentalFlags"; diff --git a/src/screens/Learn/index.tsx b/src/screens/Learn/index.tsx index 8341980d42..907efed7ed 100644 --- a/src/screens/Learn/index.tsx +++ b/src/screens/Learn/index.tsx @@ -3,9 +3,12 @@ import { SafeAreaView } from "react-native"; import WebView from "react-native-webview"; import styled, { useTheme } from "styled-components/native"; import { useTranslation } from "react-i18next"; +import useEnv from "@ledgerhq/live-common/lib/hooks/useEnv"; import extraStatusBarPadding from "../../logic/extraStatusBarPadding"; -const learnURL = "https://www.ledger.com/ledger-live-learn"; +const learnProdURL = "https://www.ledger.com/ledger-live-learn"; +const learnStagingURL = + "https://ecommerce-website.aws.stg.ldg-tech.com/ledger-live-learn"; const SafeContainer = styled(SafeAreaView)` flex: 1; @@ -23,7 +26,11 @@ export default function Learn() { colors: { type: themeType }, } = useTheme(); - const uri = `${learnURL}?theme=${themeType}&lang=${i18n.languages[0]}`; + const useStagingURL = useEnv("USE_LEARN_STAGING_URL"); + + const uri = `${ + useStagingURL ? learnStagingURL : learnProdURL + }?theme=${themeType}&lang=${i18n.languages[0]}`; return ( diff --git a/yarn.lock b/yarn.lock index 1836939c38..3e52da5c0b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2479,10 +2479,9 @@ bignumber.js "^9.0.1" json-rpc-2.0 "^0.2.16" -"@ledgerhq/live-common@^21.33.0": +"@ledgerhq/live-common@https://github.com/LedgerHQ/ledger-live-common.git#c14a6b5c83cfffe0a7e1e3de50f64f96bfc7449a": version "21.33.0" - resolved "https://registry.yarnpkg.com/@ledgerhq/live-common/-/live-common-21.33.0.tgz#4b709dcbccdcb5010fd19b6829effe2a18587cc3" - integrity sha512-CpMiASJjLOYCz59EqjGEe3p7JxoF062RpbVuaF2AIBje09kxu9kVeqBeOQpk2bx+jLH2t3yWvmqVh9E1sm9FyA== + resolved "https://github.com/LedgerHQ/ledger-live-common.git#c14a6b5c83cfffe0a7e1e3de50f64f96bfc7449a" dependencies: "@celo/contractkit" "^1.5.1" "@celo/wallet-base" "^1.5.1"