[LWDM] fix(desktop): show price and countervalue for tiny-balance assets#15608
[LWDM] fix(desktop): show price and countervalue for tiny-balance assets#15608
Conversation
Web Tools Build Status
|
There was a problem hiding this comment.
Pull request overview
Fixes asset distribution display issues for assets whose balances/countervalues round to 0, ensuring they still appear with price and countervalue in the desktop dashboard, and adjusts countervalue handling in the countervalues portfolio logic.
Changes:
- Update
getAssetsDistributioncountervalue inclusion check to treat0as a valid value. - Always render
PriceandCounterValuein the desktop Asset Distribution row (even whendistribution === 0). - Add unit tests for the portfolio distribution and the desktop row rendering; add changesets for affected packages.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| libs/live-countervalues/src/portfolio.ts | Adjusts countervalue presence check in assets distribution aggregation. |
| libs/live-countervalues/src/portfolio.test.ts | Adds a test intended to cover countervalue === 0 distribution behavior. |
| apps/ledger-live-desktop/src/renderer/screens/dashboard/AssetDistribution/Row.tsx | Removes conditional rendering so Price/CounterValue always render. |
| apps/ledger-live-desktop/src/renderer/screens/dashboard/AssetDistribution/Row.test.tsx | Adds a regression test ensuring Price/CounterValue render when distribution is 0. |
| .changeset/gentle-coins-appear.md | Declares version bump for @ledgerhq/live-countervalues. |
| .changeset/bright-rows-shine.md | Declares version bump for ledger-live-desktop. |
|
… in distribution The condition `if (cv)` treated 0 as falsy, excluding assets whose countervalue rounds to 0 from the distribution list. Use an explicit null/undefined check so that cv === 0 is kept.
a327fd5 to
9b7da6d
Compare
9b7da6d to
65d1f94
Compare
| balanceAvailable: accounts.length === 0 || availables.length > 0, | ||
| availableAccounts: availables.map(a => a.account), | ||
| unavailableCurrencies: [...new Set(unavailableAccounts.map(getAccountCurrency))], | ||
| unavailableCurrencies: [...new Set(unavailableAccounts.map(a => getAccountCurrency(a)))], |
There was a problem hiding this comment.
it's the same no?
but more readable
There was a problem hiding this comment.
I touched this file at one point and SonarQube flagged it.
It does have a good argument:
This can cause unexpected behavior in two scenarios:
- Function signature changes: If the referenced function is later modified to accept additional parameters, it may start using the index or array arguments unintentionally, leading to different behavior.
- Unintended parameter usage: The function might already accept multiple parameters for other purposes, causing it to misinterpret the index or array as meaningful input.
Personally I like the shorthand but I don't like getting a big red mark from SonarQube
Since I reverted my changes in this file I could revert this too. WDYT?
| import { useCurrencyColor } from "~/renderer/getCurrencyColor"; | ||
| import styled, { css } from "styled-components"; | ||
| import CounterValue, { NoCountervaluePlaceholder } from "~/renderer/components/CounterValue"; | ||
| import CounterValue from "~/renderer/components/CounterValue"; |
There was a problem hiding this comment.
InFine it's a product spec that changed right?
There was a problem hiding this comment.
I'm not sure I understand your point
NoCountervaluePlaceholder gets rendered conditionally within Price and CounterValue components
| jest.mock("LLD/hooks/redux", () => ({ | ||
| useSelector: jest.fn(() => "en-US"), | ||
| useDispatch: jest.fn(() => jest.fn()), | ||
| })); |
There was a problem hiding this comment.
You can achieve that just with overriding initialState of render()
There was a problem hiding this comment.
Thanks. I'll look into this and the similar comments
| jest.mock("~/renderer/hooks/useTheme", () => | ||
| jest.fn(() => ({ | ||
| colors: { | ||
| background: { | ||
| card: "#111111", | ||
| }, | ||
| neutral: { | ||
| c100: "#ffffff", | ||
| }, | ||
| error: { | ||
| c50: "#ff0000", | ||
| }, | ||
| }, | ||
| })), | ||
| ); |
There was a problem hiding this comment.
not needed as you use testSetup
| jest.mock("~/renderer/analytics/TrackPage", () => ({ | ||
| setTrackingSource: jest.fn(), | ||
| })); |
…ion rows Remove conditional rendering that hid Price and CounterValue components when distribution was 0. Tiny-balance assets now display their price and value instead of a placeholder dash.
65d1f94 to
2b32679
Compare
| --- | ||
| "@ledgerhq/live-countervalues": minor | ||
| --- | ||
|
|
||
| Fix asset distribution to include assets with zero countervalue |
There was a problem hiding this comment.
This changeset indicates a user-facing fix in @ledgerhq/live-countervalues (“include assets with zero countervalue”), but this PR doesn’t introduce a corresponding runtime behavior change in that package (only a small refactor + tests). Please either remove this changeset or update it to match an actual published behavior/API change, to avoid an unnecessary semver bump and misleading release notes.
| import React from "react"; | ||
| import { getCryptoCurrencyById } from "@ledgerhq/live-common/currencies/index"; | ||
| import { render, screen } from "tests/testSetup"; | ||
| import Row from "./Row"; | ||
| import type { DistributionItem } from "@ledgerhq/types-live"; |
There was a problem hiding this comment.
This test uses the generic render helper, which doesn’t provide a seeded countervalues state; that forces the test to mock Price/CounterValue and ends up asserting implementation details. Consider using renderWithMockedCounterValuesProvider (or otherwise seeding countervalues) and asserting on the actual rendered price/countervalue output (or the absence of the “-” placeholder) instead.
| jest.mock("~/renderer/components/Price", () => ({ | ||
| __esModule: true, | ||
| default: (props: unknown) => mockedPrice(props), | ||
| })); | ||
|
|
||
| jest.mock("~/renderer/components/CounterValue", () => ({ | ||
| __esModule: true, | ||
| default: (props: unknown) => mockedCounterValue(props), | ||
| })); |
There was a problem hiding this comment.
Mocking ~/renderer/components/Price and ~/renderer/components/CounterValue makes this test tightly coupled to the Row’s internal composition. Prefer exercising the real components with a mocked countervalues provider/state (via existing test helpers) and assert on user-visible output; this will better catch regressions while avoiding component-level mock maintenance.
|



✅ Checklist
npx changesetwas attached.📝 Description
Problem: Assets with very small balances whose % distribution of portfolio rounds to 0 did not show value or price in the asset distribution dashboard. This happened because:
Rowcomponent, thePriceandCounterValuecomponents were conditionally rendered based ondistributionbeing truthy — when distribution was0, a placeholder dash was shown instead of the actual price/value.Solution:
Row.tsxso thatPriceandCounterValuealways render, even when the distribution percentage rounds to 0.Also done:
getAssetsDistributionincluded assets with a counter value of 0. This was not clear before and led to unnecessary changes to Portfolio.ts❓ Context
🧐 Checklist for the PR Reviewers