Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lld): fix countervalues release #7154

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-rules-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

fix cvs wrong value
12 changes: 2 additions & 10 deletions apps/ledger-live-desktop/src/renderer/components/TokenRow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import Box from "~/renderer/components/Box";
import { Account, AccountLike, PortfolioRange } from "@ledgerhq/types-live";
import { getMainAccount } from "@ledgerhq/live-common/account/index";
import { getAccountCurrency } from "@ledgerhq/live-common/account/index";
import styled from "styled-components";
import Header from "~/renderer/screens/accounts/AccountRowItem/Header";
import Balance from "~/renderer/screens/accounts/AccountRowItem/Balance";
Expand All @@ -10,7 +10,6 @@ import Countervalue from "~/renderer/screens/accounts/AccountRowItem/Countervalu
import Star from "~/renderer/components/Stars/Star";
import { TableRow } from "./TableContainer";
import { useAccountUnit } from "../hooks/useAccountUnit";

type Props = {
account: AccountLike;
nested?: boolean;
Expand All @@ -19,7 +18,6 @@ type Props = {
onClick: (b: AccountLike, a: Account) => void;
range: PortfolioRange;
};

const NestedRow = styled(Box)`
flex: 1;
font-weight: 600;
Expand All @@ -38,17 +36,12 @@ const NestedRow = styled(Box)`
background: ${p => p.theme.colors.palette.action.hover};
}
`;

function TokenRow(props: Props) {
const { account, parentAccount, onClick, range, nested, disableRounding } = props;

const onClickRow = () => onClick(account, parentAccount);

const mainAccount = getMainAccount(account, parentAccount);
const unit = useAccountUnit(account);
const currency = mainAccount.currency;
const currency = getAccountCurrency(account);
const Row = nested ? NestedRow : TableRow;

return (
<Row className="token-row" onClick={onClickRow} tabIndex={-1}>
<Header nested={nested} account={account} />
Expand All @@ -59,5 +52,4 @@ function TokenRow(props: Props) {
</Row>
);
}

export default React.memo(TokenRow);
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { useAccountUnit } from "~/renderer/hooks/useAccountUnit";
import { getDefaultAccountName } from "@ledgerhq/live-wallet/accountName";
import { walletSelector } from "~/renderer/reducers/wallet";
import { accountNameSelector } from "@ledgerhq/live-wallet/store";

const Row = styled(Box)`
background: ${p => p.theme.colors.palette.background.paper};
border-radius: 4px;
Expand Down Expand Up @@ -97,14 +96,12 @@ const TokenShowMoreIndicator = styled(Button)<{ expanded?: boolean }>`
height: 32px;
text-align: center;
padding: 0;

&:hover ${Text} {
text-decoration: underline;
}
&:hover {
background-color: initial;
}

> :nth-child(2) {
margin-left: 8px;
transform: rotate(${p => (p.expanded ? "180deg" : "0deg")});
Expand All @@ -127,16 +124,13 @@ type Props = {
range: PortfolioRange;
search?: string;
};

const expandedStates: {
[key: string]: boolean;
} = {};
const AccountRowItem = (props: Props) => {
const { account, parentAccount, range, hidden, onClick, disableRounding, search } = props;

const walletState = useSelector(walletSelector);
const blacklistedTokenIds = useSelector(blacklistedTokenIdsSelector);

const [expanded, setExpanded] = useState<boolean>(
account.type === "Account" && account.subAccounts
? expandedStates[account.id] || !!search
Expand All @@ -145,45 +139,36 @@ const AccountRowItem = (props: Props) => {

const scrollTopFocusRef = useRef<HTMLSpanElement>(null);

const mountedRef = useRef(true);

useEffect(() => {
if (mountedRef.current) {
mountedRef.current = false;
return;
}
setExpanded(!!search);
}, [search]);

const toggleAccordion = (e: SyntheticEvent<HTMLDivElement>) => {
e.stopPropagation();
expandedStates[account.id] = !expandedStates[account.id];
setExpanded(expandedStates[account.id]);
if (scrollTopFocusRef.current && !expanded) {
scrollTopFocusRef.current.scrollIntoView({
block: "nearest",
behavior: "smooth",
});
}
}, [expanded]);

const toggleAccordion = (e: SyntheticEvent<HTMLDivElement>) => {
e.stopPropagation();
expandedStates[account.id] = !expandedStates[account.id];
setExpanded(expandedStates[account.id]);
};

const onClickHandler = () => onClick(account, parentAccount);

const unit = useAccountUnit(account);

let currency;
let mainAccount: Account | null | undefined;
let tokens;
let disabled;
let isToken;
if (account.type !== "Account") {
currency = account.token;

mainAccount = parentAccount;
isToken = mainAccount && listTokenTypesForCryptoCurrency(mainAccount.currency).length > 0;
if (!mainAccount) return null;
} else {
currency = account.currency;

mainAccount = account;
tokens = listSubAccounts(account).filter(
subAccount => !blacklistedTokenIds.includes(getAccountCurrency(subAccount).id),
Expand Down Expand Up @@ -211,7 +196,6 @@ const AccountRowItem = (props: Props) => {
const key = `${account.id}`;
const accountName =
accountNameSelector(walletState, { accountId: account.id }) || getDefaultAccountName(account);

return (
<div
className={`accounts-account-row-item ${tokens && tokens.length > 0 ? "has-tokens" : ""}`}
Expand Down
Loading