From 31a12e7a08d0f16698ad68b4c0231d34d76b3994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Grellard?= Date: Fri, 20 Sep 2024 11:25:34 +0200 Subject: [PATCH] LLM - Update Storyly and fixes issues (#7841) * fix(llm): update storyly and fixes issues * fix(llm): update storyly and fixes issues * fix(llm): fix storyly type --- .changeset/sixty-insects-rescue.md | 5 +++++ apps/ledger-live-mobile/ios/Podfile.lock | 10 +++++----- apps/ledger-live-mobile/package.json | 2 +- .../components/StorylyStories/StorylyProvider.tsx | 12 +++++++++--- .../src/components/StorylyStories/StorylyWrapper.tsx | 1 + .../src/components/StorylyStories/index.tsx | 4 ++-- .../src/navigation/DeeplinksProvider.tsx | 4 ++++ pnpm-lock.yaml | 10 +++++----- 8 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 .changeset/sixty-insects-rescue.md diff --git a/.changeset/sixty-insects-rescue.md b/.changeset/sixty-insects-rescue.md new file mode 100644 index 000000000000..c73ea637ab66 --- /dev/null +++ b/.changeset/sixty-insects-rescue.md @@ -0,0 +1,5 @@ +--- +"live-mobile": patch +--- + +LLM - Update Storyly and fix some issues diff --git a/apps/ledger-live-mobile/ios/Podfile.lock b/apps/ledger-live-mobile/ios/Podfile.lock index 2c06261a7d4a..afb44f48e292 100644 --- a/apps/ledger-live-mobile/ios/Podfile.lock +++ b/apps/ledger-live-mobile/ios/Podfile.lock @@ -1398,10 +1398,10 @@ PODS: - SocketRocket (0.6.1) - sovran-react-native (0.4.5): - React-Core - - Storyly (2.18.1) - - storyly-react-native (2.18.1): + - Storyly (3.6.0) + - storyly-react-native (3.6.0): - React - - Storyly (= 2.18.1) + - Storyly (= 3.6.0) - TOCropViewController (2.5.3) - Yoga (1.14.0) - ZXingObjC/Core (3.6.9) @@ -1959,8 +1959,8 @@ SPEC CHECKSUMS: SentryPrivate: d651efb234cf385ec9a1cdd3eff94b5e78a0e0fe SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17 sovran-react-native: fd3dc8f1a4b14acdc4ad25fc6b4ac4f52a2a2a15 - Storyly: 97332ff6eccc9ce4024207338f88b34177c95503 - storyly-react-native: a112c85399fefc126d8d6a7d692be1b7a12bfaa7 + Storyly: 310297bcf4493d3d5b41e71834fba49502c8067a + storyly-react-native: f14aab1a353a8c685b1ab3371fb5fd0c028bc311 TOCropViewController: 20a14b6a7a098308bf369e7c8d700dc983a974e6 Yoga: 805bf71192903b20fc14babe48080582fee65a80 ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5 diff --git a/apps/ledger-live-mobile/package.json b/apps/ledger-live-mobile/package.json index 00777bf51928..02d72fb60e48 100644 --- a/apps/ledger-live-mobile/package.json +++ b/apps/ledger-live-mobile/package.json @@ -217,7 +217,7 @@ "rn-fetch-blob": "^0.12.0", "rxjs": "^7.8.1", "semver": "^7.3.7", - "storyly-react-native": "2.18.1", + "storyly-react-native": "3.6.0", "styled-components": "^5.3.3", "styled-system": "^5.1.5", "text-encoding-polyfill": "^0.6.7", diff --git a/apps/ledger-live-mobile/src/components/StorylyStories/StorylyProvider.tsx b/apps/ledger-live-mobile/src/components/StorylyStories/StorylyProvider.tsx index 9df63a673dea..6d6a5deda9b6 100644 --- a/apps/ledger-live-mobile/src/components/StorylyStories/StorylyProvider.tsx +++ b/apps/ledger-live-mobile/src/components/StorylyStories/StorylyProvider.tsx @@ -4,6 +4,7 @@ import { Linking } from "react-native"; import { Feature_Storyly, StorylyInstanceType } from "@ledgerhq/types-live"; import React, { createContext, useState, useContext, ReactNode, useRef, useEffect } from "react"; import { Storyly } from "storyly-react-native"; +import { useSettings } from "~/hooks"; interface StorylyProviderProps { children: ReactNode; @@ -27,6 +28,7 @@ const getTokenForInstanceId = (stories: StoriesType, targetInstanceId: string): const StorylyProvider: React.FC = ({ children }) => { const [url, setUrl] = useState(null); const [token, setToken] = useState(null); + const { language } = useSettings(); const storylyRef = useRef(null); @@ -61,11 +63,14 @@ const StorylyProvider: React.FC = ({ children }) => { }; const handleEvent = (e: Storyly.StoryEvent) => { - if (["StoryGroupClosed", "StoryGroupCompleted", "StoryPaused"].includes(e.event)) { + if ( + (e.event === "StoryPreviousClicked" && e.story?.index === 0) || + ["StoryGroupClosed", "StoryGroupCompleted"].includes(e.event) + ) { clear(); } - if (e.event === "StoryCTAClicked" && e?.story?.media?.actionUrl) { - Linking.openURL(e.story.media.actionUrl); + if (e.event === "StoryCTAClicked" && e?.story?.actionUrl) { + Linking.openURL(e.story.actionUrl); clear(); } }; @@ -81,6 +86,7 @@ const StorylyProvider: React.FC = ({ children }) => { style={{ flex: 1 }} // necessary for touches to work onLoad={handleLoad} onEvent={handleEvent} + storylyLocale={language} /> ) : null} diff --git a/apps/ledger-live-mobile/src/components/StorylyStories/StorylyWrapper.tsx b/apps/ledger-live-mobile/src/components/StorylyStories/StorylyWrapper.tsx index fa044af58c33..b3c9e5dd1d9e 100644 --- a/apps/ledger-live-mobile/src/components/StorylyStories/StorylyWrapper.tsx +++ b/apps/ledger-live-mobile/src/components/StorylyStories/StorylyWrapper.tsx @@ -57,6 +57,7 @@ const StorylyLocalizedWrapper = forwardRef((props: Props, ref: ForwardedRef = props => { const newStoryGroupList = computeNewStoryGroupList(storyGroupList, event); if (!isEqual(storyGroupList, newStoryGroupList)) setStoryGroupList(newStoryGroupList); } - if (event.event === "StoryCTAClicked" && event?.story?.media?.actionUrl) { - Linking.openURL(event.story.media.actionUrl); + if (event.event === "StoryCTAClicked" && event?.story?.actionUrl) { + Linking.openURL(event.story.actionUrl); storylyRef.current?.closeStory?.(); } }, diff --git a/apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx b/apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx index b2af4c3f6aea..ebbd52345b89 100644 --- a/apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx +++ b/apps/ledger-live-mobile/src/navigation/DeeplinksProvider.tsx @@ -516,6 +516,10 @@ export const DeeplinksProvider = ({ } const platform = pathname.split("/")[1]; + if (isStorylyLink(url.toString())) { + storylyContext.setUrl(url.toString()); + } + if (hostname === "earn") { if (searchParams.get("action") === "info-modal") { const message = searchParams.get("message") ?? ""; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 35a3f0b74610..d157542b424a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1235,8 +1235,8 @@ importers: specifier: ^7.3.7 version: 7.5.4 storyly-react-native: - specifier: 2.18.1 - version: 2.18.1(prop-types@15.8.1)(react-native@0.73.6(@babel/core@7.24.3)(react@18.2.0))(react@18.2.0) + specifier: 3.6.0 + version: 3.6.0(prop-types@15.8.1)(react-native@0.73.6(@babel/core@7.24.3)(react@18.2.0))(react@18.2.0) styled-components: specifier: ^5.3.3 version: 5.3.11(@babel/core@7.24.3)(react-is@18.2.0)(react@18.2.0) @@ -27838,8 +27838,8 @@ packages: resolution: {integrity: sha512-Wt04pPTO71pwmRmsgkyZhNo4Bvdb/1pBAMsIFb9nQLykEdzzpXjvingxFFvdOG4nIowzwgxD+CLlyRqVJqnATw==} hasBin: true - storyly-react-native@2.18.1: - resolution: {integrity: sha512-obmcEiqaMk6MRHg8kaN7AV2bKqOAMFEwC3dFmTbEsfPVCt5IEnSjhtzZ9kYkfndjPiEzvq1ySiZ9GUysxL83NQ==} + storyly-react-native@3.6.0: + resolution: {integrity: sha512-YDHTQe6W91GMZ6jlV+tstJNTvBK2PWWqGLBZUovdbrq3Sh1evzbGC5cG0yicH752FGRDC/U0sjTE8FBuiRwVUg==} peerDependencies: prop-types: '*' react: ^18.0.0 @@ -62919,7 +62919,7 @@ snapshots: - supports-color - utf-8-validate - storyly-react-native@2.18.1(prop-types@15.8.1)(react-native@0.73.6(@babel/core@7.24.3)(react@18.2.0))(react@18.2.0): + storyly-react-native@3.6.0(prop-types@15.8.1)(react-native@0.73.6(@babel/core@7.24.3)(react@18.2.0))(react@18.2.0): dependencies: react: 18.2.0 react-native: 0.73.6(@babel/core@7.24.3)(react@18.2.0)