diff --git a/.changeset/tricky-forks-fly.md b/.changeset/tricky-forks-fly.md new file mode 100644 index 000000000000..0efcf03092ef --- /dev/null +++ b/.changeset/tricky-forks-fly.md @@ -0,0 +1,5 @@ +--- +"live-mobile": patch +--- + +fix: freeze when opening a live-app diff --git a/apps/ledger-live-mobile/src/components/WebPlatformPlayer/BottomBar.tsx b/apps/ledger-live-mobile/src/components/WebPlatformPlayer/BottomBar.tsx index 28b421601bf9..324b059e43e5 100644 --- a/apps/ledger-live-mobile/src/components/WebPlatformPlayer/BottomBar.tsx +++ b/apps/ledger-live-mobile/src/components/WebPlatformPlayer/BottomBar.tsx @@ -1,17 +1,12 @@ import React, { RefObject, useCallback } from "react"; import { TouchableOpacity } from "react-native"; -import { Flex, Text } from "@ledgerhq/native-ui"; +import { Flex } from "@ledgerhq/native-ui"; import { ArrowLeftMedium, ArrowRightMedium, ReverseMedium } from "@ledgerhq/native-ui/assets/icons"; import { useTheme } from "styled-components/native"; import { AppManifest } from "@ledgerhq/live-common/wallet-api/types"; -import { useDappCurrentAccount } from "@ledgerhq/live-common/wallet-api/useDappLogic"; import { safeGetRefValue, CurrentAccountHistDB } from "@ledgerhq/live-common/wallet-api/react"; import { WebviewAPI, WebviewState } from "../Web3AppWebview/types"; -import Button from "../Button"; -import { Trans } from "react-i18next"; -import CircleCurrencyIcon from "../CircleCurrencyIcon"; -import { useSelectAccount } from "../Web3AppWebview/helpers"; -import { useMaybeAccountName } from "~/reducers/wallet"; +import SelectAccountButton from "./SelectAccountButton"; type BottomBarProps = { manifest: AppManifest; @@ -48,7 +43,6 @@ export function BottomBar({ currentAccountHistDb, }: BottomBarProps) { const { colors } = useTheme(); - const { currentAccount } = useDappCurrentAccount(currentAccountHistDb); const shouldDisplaySelectAccount = !!manifest.dapp; const handleForward = useCallback(() => { @@ -69,10 +63,6 @@ export function BottomBar({ webview.reload(); }, [webviewAPIRef]); - const { onSelectAccount } = useSelectAccount({ manifest, currentAccountHistDb }); - - const currentAccountName = useMaybeAccountName(currentAccount); - return ( @@ -92,27 +82,7 @@ export function BottomBar({ {shouldDisplaySelectAccount ? ( - + ) : null} diff --git a/apps/ledger-live-mobile/src/components/WebPlatformPlayer/SelectAccountButton.tsx b/apps/ledger-live-mobile/src/components/WebPlatformPlayer/SelectAccountButton.tsx new file mode 100644 index 000000000000..9a2568fa4dfc --- /dev/null +++ b/apps/ledger-live-mobile/src/components/WebPlatformPlayer/SelectAccountButton.tsx @@ -0,0 +1,50 @@ +import React from "react"; +import { Trans } from "react-i18next"; +import { Flex, Text } from "@ledgerhq/native-ui"; +import { AppManifest } from "@ledgerhq/live-common/wallet-api/types"; +import { CurrentAccountHistDB } from "@ledgerhq/live-common/wallet-api/react"; +import { useDappCurrentAccount } from "@ledgerhq/live-common/wallet-api/useDappLogic"; +import Button from "~/components/Button"; +import CircleCurrencyIcon from "~/components/CircleCurrencyIcon"; +import { useSelectAccount } from "~/components/Web3AppWebview/helpers"; +import { useMaybeAccountName } from "~/reducers/wallet"; + +type SelectAccountButtonProps = { + manifest: AppManifest; + currentAccountHistDb: CurrentAccountHistDB; +}; + +export default function SelectAccountButton({ + manifest, + currentAccountHistDb, +}: SelectAccountButtonProps) { + const { currentAccount } = useDappCurrentAccount(currentAccountHistDb); + + const { onSelectAccount } = useSelectAccount({ manifest, currentAccountHistDb }); + + const currentAccountName = useMaybeAccountName(currentAccount); + + return ( + + ); +} diff --git a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubApp/components/Web3Player/BottomBar.tsx b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubApp/components/Web3Player/BottomBar.tsx index 551d92030476..e09a05bf44cb 100644 --- a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubApp/components/Web3Player/BottomBar.tsx +++ b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubApp/components/Web3Player/BottomBar.tsx @@ -1,23 +1,18 @@ import React, { RefObject, useCallback } from "react"; import { TouchableOpacity } from "react-native"; import { useTheme } from "@react-navigation/native"; -import { Trans } from "react-i18next"; import Animated, { useAnimatedStyle, interpolate, Extrapolation, SharedValue, } from "react-native-reanimated"; -import { Flex, Text } from "@ledgerhq/native-ui"; +import { Flex } from "@ledgerhq/native-ui"; import { AppManifest } from "@ledgerhq/live-common/wallet-api/types"; import { ArrowLeftMedium, ArrowRightMedium, ReverseMedium } from "@ledgerhq/native-ui/assets/icons"; import { safeGetRefValue, CurrentAccountHistDB } from "@ledgerhq/live-common/wallet-api/react"; -import { useDappCurrentAccount } from "@ledgerhq/live-common/wallet-api/useDappLogic"; import { WebviewAPI, WebviewState } from "~/components/Web3AppWebview/types"; -import Button from "~/components/Button"; -import CircleCurrencyIcon from "~/components/CircleCurrencyIcon"; -import { useSelectAccount } from "~/components/Web3AppWebview/helpers"; -import { useMaybeAccountName } from "~/reducers/wallet"; +import SelectAccountButton from "./SelectAccountButton"; const BAR_HEIGHT = 60; export const TOTAL_HEADER_HEIGHT = BAR_HEIGHT; @@ -61,7 +56,6 @@ export function BottomBar({ layoutY, }: BottomBarProps) { const { colors } = useTheme(); - const { currentAccount } = useDappCurrentAccount(currentAccountHistDb); const shouldDisplaySelectAccount = !!manifest.dapp; const handleForward = useCallback(() => { @@ -82,10 +76,6 @@ export function BottomBar({ webview.reload(); }, [webviewAPIRef]); - const { onSelectAccount } = useSelectAccount({ manifest, currentAccountHistDb }); - - const currentAccountName = useMaybeAccountName(currentAccount); - const heightStyle = useAnimatedStyle(() => { if (!layoutY) return {}; @@ -132,27 +122,7 @@ export function BottomBar({ {shouldDisplaySelectAccount ? ( - + ) : null} diff --git a/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubApp/components/Web3Player/SelectAccountButton.tsx b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubApp/components/Web3Player/SelectAccountButton.tsx new file mode 100644 index 000000000000..9a2568fa4dfc --- /dev/null +++ b/apps/ledger-live-mobile/src/newArch/features/Web3Hub/screens/Web3HubApp/components/Web3Player/SelectAccountButton.tsx @@ -0,0 +1,50 @@ +import React from "react"; +import { Trans } from "react-i18next"; +import { Flex, Text } from "@ledgerhq/native-ui"; +import { AppManifest } from "@ledgerhq/live-common/wallet-api/types"; +import { CurrentAccountHistDB } from "@ledgerhq/live-common/wallet-api/react"; +import { useDappCurrentAccount } from "@ledgerhq/live-common/wallet-api/useDappLogic"; +import Button from "~/components/Button"; +import CircleCurrencyIcon from "~/components/CircleCurrencyIcon"; +import { useSelectAccount } from "~/components/Web3AppWebview/helpers"; +import { useMaybeAccountName } from "~/reducers/wallet"; + +type SelectAccountButtonProps = { + manifest: AppManifest; + currentAccountHistDb: CurrentAccountHistDB; +}; + +export default function SelectAccountButton({ + manifest, + currentAccountHistDb, +}: SelectAccountButtonProps) { + const { currentAccount } = useDappCurrentAccount(currentAccountHistDb); + + const { onSelectAccount } = useSelectAccount({ manifest, currentAccountHistDb }); + + const currentAccountName = useMaybeAccountName(currentAccount); + + return ( + + ); +}