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: delegation showless #8744

Merged
merged 1 commit into from
Dec 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/hungry-ravens-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

Choosing a new provider outside the ledger one is now displayed in the modal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useValidators } from "@ledgerhq/live-common/families/solana/react";
import { ValidatorsAppValidator } from "@ledgerhq/live-common/families/solana/staking";
import { SolanaAccount } from "@ledgerhq/live-common/families/solana/types";

import React, { useState, useCallback } from "react";
import React, { useState, useCallback, useEffect } from "react";
import { Trans } from "react-i18next";
import styled from "styled-components";
import Box from "~/renderer/components/Box";
Expand All @@ -23,6 +23,8 @@ type Props = {
const ValidatorField = ({ account, onChangeValidator, chosenVoteAccAddr }: Props) => {
const [search, setSearch] = useState("");
const [showAll, setShowAll] = useState(false);
const [currentValidator, setCurrentValidator] = useState<ValidatorsAppValidator[]>([]);

const unit = useAccountUnit(account);
const validators = useValidators(account.currency, search);

Expand All @@ -31,6 +33,21 @@ const ValidatorField = ({ account, onChangeValidator, chosenVoteAccAddr }: Props
[setSearch],
);

useEffect(() => {
const selectedVoteAccAddr = validators.find(p => p.voteAccount === chosenVoteAccAddr);
if (selectedVoteAccAddr) {
const isDefault = validators.slice(0, 2).includes(selectedVoteAccAddr);
if (isDefault) {
setCurrentValidator([selectedVoteAccAddr]);
}
setCurrentValidator([
selectedVoteAccAddr,
...validators.slice(0, 2).filter(v => v !== selectedVoteAccAddr),
]);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [chosenVoteAccAddr]);

const renderItem = (validator: ValidatorsAppValidator) => {
return (
<ValidatorRow
Expand All @@ -49,7 +66,13 @@ const ValidatorField = ({ account, onChangeValidator, chosenVoteAccAddr }: Props
<ValidatorsFieldContainer>
<Box p={1} data-testid="validator-list">
<ScrollLoadingList
data={showAll ? validators : validators.slice(0, 2)}
data={
showAll
? validators
: currentValidator.length > 0
? currentValidator
: validators.slice(0, 2)
}
style={{
flex: showAll ? "1 0 240px" : "1 0 126px",
marginBottom: 0,
Expand Down
Loading