mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-12 17:10:56 +00:00
fix selected coins at start, handle not visible coins properly
This commit is contained in:
parent
bf47a1684b
commit
7abc4a61fe
@ -367,7 +367,7 @@ export const handleCoinVisibility = (
|
||||
let newConfig: Array<string> = configuration;
|
||||
const isAlreadyHidden = configuration.find(coin => coin === coinShortcut);
|
||||
|
||||
if (isAlreadyHidden && shouldBeVisible) {
|
||||
if (shouldBeVisible) {
|
||||
newConfig = configuration.filter(coin => coin !== coinShortcut);
|
||||
} else if (!isAlreadyHidden) {
|
||||
newConfig = [...configuration, coinShortcut];
|
||||
|
@ -60,7 +60,7 @@ class CoinMenu extends PureComponent<Props> {
|
||||
return coins
|
||||
.sort((a, b) => a.order - b.order)
|
||||
.filter(item => !item.isHidden) // hide coins globally in config
|
||||
.filter(item => hiddenCoins.includes(item.id))
|
||||
.filter(item => !hiddenCoins.includes(item.id))
|
||||
.map(coin => {
|
||||
const row = (
|
||||
<RowCoin
|
||||
@ -105,7 +105,7 @@ class CoinMenu extends PureComponent<Props> {
|
||||
const { hiddenCoins } = this.props.wallet;
|
||||
const numberOfVisibleNetworks = coins
|
||||
.filter(item => !item.isHidden)
|
||||
.filter(item => hiddenCoins.includes(item.id));
|
||||
.filter(item => !hiddenCoins.includes(item.id));
|
||||
|
||||
return numberOfVisibleNetworks.length <= 0;
|
||||
}
|
||||
@ -129,7 +129,7 @@ class CoinMenu extends PureComponent<Props> {
|
||||
)}
|
||||
{config.networks
|
||||
.filter(item => !item.isHidden) // hide coins globally in config
|
||||
.filter(item => hiddenCoins.includes(item.shortcut)) // hide coins by user settings
|
||||
.filter(item => !hiddenCoins.includes(item.shortcut)) // hide coins by user settings
|
||||
.sort((a, b) => a.order - b.order)
|
||||
.map(item => (
|
||||
<NavLink
|
||||
|
@ -76,7 +76,7 @@ const Dashboard = (props: Props) => (
|
||||
<Coins>
|
||||
{props.localStorage.config.networks
|
||||
.filter(item => !item.isHidden)
|
||||
.filter(item => props.wallet.hiddenCoins.includes(item.shortcut))
|
||||
.filter(item => !props.wallet.hiddenCoins.includes(item.shortcut))
|
||||
.map(network => (
|
||||
<StyledNavLink
|
||||
key={network.shortcut}
|
||||
|
@ -107,10 +107,10 @@ const CoinsSettings = (props: Props) => (
|
||||
</Left>
|
||||
<Right>
|
||||
<Switch
|
||||
onChange={isVisible => {
|
||||
props.handleCoinVisibility(network.shortcut, !isVisible);
|
||||
onChange={visible => {
|
||||
props.handleCoinVisibility(network.shortcut, visible);
|
||||
}}
|
||||
checked={props.hiddenCoins.includes(network.shortcut)}
|
||||
checked={!props.hiddenCoins.includes(network.shortcut)}
|
||||
/>
|
||||
</Right>
|
||||
</CoinRow>
|
||||
@ -139,10 +139,10 @@ const CoinsSettings = (props: Props) => (
|
||||
</Left>
|
||||
<Right>
|
||||
<Switch
|
||||
onChange={isVisible => {
|
||||
props.handleCoinVisibility(network.id, !isVisible);
|
||||
onChange={visible => {
|
||||
props.handleCoinVisibility(network.id, visible);
|
||||
}}
|
||||
checked={props.hiddenCoins.includes(network.id)}
|
||||
checked={!props.hiddenCoins.includes(network.id)}
|
||||
/>
|
||||
</Right>
|
||||
</CoinRow>
|
||||
|
Loading…
Reference in New Issue
Block a user