-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7625 from LedgerHQ/bugfix/LIVE-13411
fix: freeze when opening a live-app [LIVE-13411]
- Loading branch information
Showing
5 changed files
with
111 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"live-mobile": patch | ||
--- | ||
|
||
fix: freeze when opening a live-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
apps/ledger-live-mobile/src/components/WebPlatformPlayer/SelectAccountButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Button type="primary" onPress={onSelectAccount}> | ||
{!currentAccount ? ( | ||
<Text> | ||
<Trans i18nKey="common.selectAccount" /> | ||
</Text> | ||
) : ( | ||
<Flex flexDirection="row" height={50} alignItems="center" justifyContent="center"> | ||
<CircleCurrencyIcon | ||
size={24} | ||
currency={ | ||
currentAccount.type === "TokenAccount" | ||
? currentAccount.token | ||
: currentAccount.currency | ||
} | ||
/> | ||
<Text color={"neutral.c20"} ml={4}> | ||
{currentAccountName} | ||
</Text> | ||
</Flex> | ||
)} | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...newArch/features/Web3Hub/screens/Web3HubApp/components/Web3Player/SelectAccountButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Button type="primary" onPress={onSelectAccount}> | ||
{!currentAccount ? ( | ||
<Text> | ||
<Trans i18nKey="common.selectAccount" /> | ||
</Text> | ||
) : ( | ||
<Flex flexDirection="row" height={50} alignItems="center" justifyContent="center"> | ||
<CircleCurrencyIcon | ||
size={24} | ||
currency={ | ||
currentAccount.type === "TokenAccount" | ||
? currentAccount.token | ||
: currentAccount.currency | ||
} | ||
/> | ||
<Text color={"neutral.c20"} ml={4}> | ||
{currentAccountName} | ||
</Text> | ||
</Flex> | ||
)} | ||
</Button> | ||
); | ||
} |