Skip to content

Commit

Permalink
feat 💄(llm): change add accounts button logic (#8859)
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWerey authored Jan 14, 2025
1 parent 80a46be commit e3fe89d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 17 deletions.
5 changes: 5 additions & 0 deletions .changeset/five-waves-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Change logic on portfolio assets to display add account button
33 changes: 18 additions & 15 deletions apps/ledger-live-mobile/src/screens/Portfolio/PortfolioAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ const PortfolioAssets = ({ hideEmptyTokenAccount, openAddModal }: Props) => {
[startNavigationTTITimer, showAssets, isAccountListUIEnabled, navigation],
);

const showAddAccountButton =
isAccountListUIEnabled && showAccounts && distribution.list.length >= maxItemsToDysplay;
const showAddAccountButton = isAccountListUIEnabled && showAccounts;

return (
<>
Expand All @@ -119,20 +118,24 @@ const PortfolioAssets = ({ hideEmptyTokenAccount, openAddModal }: Props) => {
) : (
<Assets assets={assetsToDisplay} />
)}
{showAddAccountButton ? <AddAccountButton sourceScreenName="Wallet" /> : null}
{distribution.list.length < maxItemsToDysplay ? (
<Button
type="shade"
size="large"
outline
mt={6}
iconPosition="left"
Icon={IconsLegacy.PlusMedium}
onPress={openAddModal}
>
{t("account.emptyState.addAccountCta")}
</Button>
{showAddAccountButton ? (
<AddAccountButton sourceScreenName="Wallet" />
) : (
distribution.list.length === 0 && (
<Button
type="shade"
size="large"
outline
mt={6}
iconPosition="left"
Icon={IconsLegacy.PlusMedium}
onPress={openAddModal}
>
{t("account.emptyState.addAccountCta")}
</Button>
)
)}
{distribution.list.length >= maxItemsToDysplay && (
<Button type="shade" size="large" outline onPress={onPressButton}>
{showAssets ? t("portfolio.seeAllAssets") : t("portfolio.seeAllAccounts")}
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("portfolioAssets", () => {
// FIXME this is not visible in the test after the animation. It seems that the useSharedValue are not updated in the test environment so cronos 2 is always not visible even if it should be visible.
});

it("should hide see all button and display add account button because there is less than 5 assets", async () => {
it("should hide see all button because there is less than 5 assets", async () => {
const { user } = render(
<TestNavigator>
<PortfolioAssets hideEmptyTokenAccount={false} openAddModal={() => null} />
Expand All @@ -71,7 +71,8 @@ describe("portfolioAssets", () => {

expect(await screen.getByTestId("AssetsList")).toBeVisible();
expect(screen.queryByText(/see all assets/i)).toBeNull();
expect(screen.getByText(/add account/i)).toBeVisible();
expect(screen.queryByText(/add account/i)).toBeNull();
expect(screen.queryByText(/add new or existing account/i)).toBeNull();

await user.press(screen.getByText(/accounts/i));

Expand All @@ -81,6 +82,8 @@ describe("portfolioAssets", () => {
});

expect(screen.queryByText(/see all accounts/i)).toBeNull();
expect(screen.queryByText(/add account/i)).toBeNull();
expect(screen.queryByText(/add new or existing account/i)).toBeVisible();

await user.press(screen.getByText(/assets/i));

Expand Down

0 comments on commit e3fe89d

Please sign in to comment.