diff --git a/.changeset/honest-badgers-develop.md b/.changeset/honest-badgers-develop.md new file mode 100644 index 000000000000..07f6a5d8ec51 --- /dev/null +++ b/.changeset/honest-badgers-develop.md @@ -0,0 +1,5 @@ +--- +"live-mobile": minor +--- + +LLM add error page diff --git a/apps/ledger-live-mobile/src/locales/en/common.json b/apps/ledger-live-mobile/src/locales/en/common.json index 75e4b3a4ef62..cbf2dea0a790 100644 --- a/apps/ledger-live-mobile/src/locales/en/common.json +++ b/apps/ledger-live-mobile/src/locales/en/common.json @@ -1019,6 +1019,12 @@ "ScannedNewImportQrCode": { "title": "Update required", "description": "To sync your apps, please make sure both are updated to the latest version." + }, + "AppManifestUnknownError": { + "title": "Swap Live App not found" + }, + "AppManifestNotFoundError": { + "title": "Failed to load Swap Live App" } }, "crash": { diff --git a/apps/ledger-live-mobile/src/screens/Swap/LiveApp/WebView.tsx b/apps/ledger-live-mobile/src/screens/Swap/LiveApp/WebView.tsx index 6ccefb19a519..032274cc57b0 100644 --- a/apps/ledger-live-mobile/src/screens/Swap/LiveApp/WebView.tsx +++ b/apps/ledger-live-mobile/src/screens/Swap/LiveApp/WebView.tsx @@ -1,16 +1,18 @@ -import React from "react"; import { LiveAppManifest } from "@ledgerhq/live-common/platform/types"; +import React from "react"; import TabBarSafeAreaView from "~/components/TabBar/TabBarSafeAreaView"; import { Web3AppWebview } from "~/components/Web3AppWebview"; +import { WebviewState } from "~/components/Web3AppWebview/types"; type Props = { manifest: LiveAppManifest; + setWebviewState: React.Dispatch>; }; -export function WebView({ manifest }: Props) { +export function WebView({ manifest, setWebviewState }: Props) { return ( - + ); } diff --git a/apps/ledger-live-mobile/src/screens/Swap/LiveApp/index.tsx b/apps/ledger-live-mobile/src/screens/Swap/LiveApp/index.tsx index b95230a701d0..2a8388579f68 100644 --- a/apps/ledger-live-mobile/src/screens/Swap/LiveApp/index.tsx +++ b/apps/ledger-live-mobile/src/screens/Swap/LiveApp/index.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; import { useRemoteLiveAppContext, @@ -7,27 +7,39 @@ import { import { LiveAppManifest } from "@ledgerhq/live-common/platform/types"; import { useLocalLiveAppManifest } from "@ledgerhq/live-common/wallet-api/LocalLiveAppProvider/index"; import { Flex, InfiniteLoader } from "@ledgerhq/native-ui"; +import { useTranslation } from "react-i18next"; import GenericErrorView from "~/components/GenericErrorView"; import TabBarSafeAreaView from "~/components/TabBar/TabBarSafeAreaView"; +import { initialWebviewState } from "~/components/Web3AppWebview/helpers"; +import { WebviewState } from "~/components/Web3AppWebview/types"; import { WebView } from "./WebView"; const DEFAULT_SWAP_APP_ID = "swap-live-app-demo-3"; -const APP_MANIFEST_NOT_FOUND_ERROR = new Error("Swap Live App not found"); export function SwapLiveApp() { + const { t } = useTranslation(); + + const APP_MANIFEST_NOT_FOUND_ERROR = new Error(t("errors.AppManifestUnknown.title")); + const APP_MANIFEST_UNKNOWN_ERROR = new Error(t("errors.AppManifestNotFoundError.title")); + const localManifest: LiveAppManifest | undefined = useLocalLiveAppManifest(DEFAULT_SWAP_APP_ID); const remoteManifest: LiveAppManifest | undefined = useRemoteLiveAppManifest(DEFAULT_SWAP_APP_ID); const { state: remoteLiveAppState } = useRemoteLiveAppContext(); + const [webviewState, setWebviewState] = useState(initialWebviewState); + const isWebviewError = webviewState?.url.includes("/unknown-error"); + const manifest: LiveAppManifest | undefined = !localManifest ? remoteManifest : localManifest; - if (!manifest) { + if (!manifest || isWebviewError) { return ( {remoteLiveAppState.isLoading ? ( ) : ( - + )} ); @@ -36,7 +48,7 @@ export function SwapLiveApp() { return ( <> - + );