diff --git a/.changeset/hungry-ravens-beg.md b/.changeset/hungry-ravens-beg.md new file mode 100644 index 000000000000..5a35829cc2c8 --- /dev/null +++ b/.changeset/hungry-ravens-beg.md @@ -0,0 +1,5 @@ +--- +"ledger-live-desktop": patch +--- + +Choosing a new provider outside the ledger one is now displayed in the modal diff --git a/apps/ledger-live-desktop/src/renderer/families/solana/shared/fields/ValidatorsField.tsx b/apps/ledger-live-desktop/src/renderer/families/solana/shared/fields/ValidatorsField.tsx index 60bf984df96a..e87747ef6339 100644 --- a/apps/ledger-live-desktop/src/renderer/families/solana/shared/fields/ValidatorsField.tsx +++ b/apps/ledger-live-desktop/src/renderer/families/solana/shared/fields/ValidatorsField.tsx @@ -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"; @@ -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([]); + const unit = useAccountUnit(account); const validators = useValidators(account.currency, search); @@ -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 ( 0 + ? currentValidator + : validators.slice(0, 2) + } style={{ flex: showAll ? "1 0 240px" : "1 0 126px", marginBottom: 0,