diff --git a/src/actions/LocalStorageActions.js b/src/actions/LocalStorageActions.js index c2fb7790..1439a1b2 100644 --- a/src/actions/LocalStorageActions.js +++ b/src/actions/LocalStorageActions.js @@ -401,21 +401,9 @@ export const toggleGroupCoinsVisibility = ( checked: boolean, isExternal: boolean ): ThunkAction => (dispatch: Dispatch) => { - if (checked && isExternal) { - dispatch({ - type: WALLET.SET_HIDDEN_COINS_EXTERNAL, - hiddenCoinsExternal: [], - }); - storageUtils.set(TYPE, KEY_HIDDEN_COINS_EXTERNAL, JSON.stringify([])); - } + // supported coins - if (!checked && isExternal) { - dispatch({ - type: WALLET.SET_HIDDEN_COINS_EXTERNAL, - hiddenCoinsExternal: allCoins, - }); - storageUtils.set(TYPE, KEY_HIDDEN_COINS_EXTERNAL, JSON.stringify(allCoins)); - } + console.log('checked', checked); if (checked && !isExternal) { dispatch({ @@ -432,6 +420,23 @@ export const toggleGroupCoinsVisibility = ( }); storageUtils.set(TYPE, KEY_HIDDEN_COINS, JSON.stringify(allCoins)); } + + // external coins + if (checked && isExternal) { + dispatch({ + type: WALLET.SET_HIDDEN_COINS_EXTERNAL, + hiddenCoinsExternal: [], + }); + storageUtils.set(TYPE, KEY_HIDDEN_COINS_EXTERNAL, JSON.stringify([])); + } + + if (!checked && isExternal) { + dispatch({ + type: WALLET.SET_HIDDEN_COINS_EXTERNAL, + hiddenCoinsExternal: allCoins, + }); + storageUtils.set(TYPE, KEY_HIDDEN_COINS_EXTERNAL, JSON.stringify(allCoins)); + } }; export const getHiddenCoins = (isExternal: boolean): Array => { diff --git a/src/views/Wallet/views/WalletSettings/components/Coins/index.js b/src/views/Wallet/views/WalletSettings/components/Coins/index.js index c2215c06..0df8ee99 100644 --- a/src/views/Wallet/views/WalletSettings/components/Coins/index.js +++ b/src/views/Wallet/views/WalletSettings/components/Coins/index.js @@ -1,6 +1,6 @@ /* @flow */ import styled from 'styled-components'; -import React from 'react'; +import React, { PureComponent } from 'react'; import { FormattedMessage } from 'react-intl'; import { FONT_SIZE } from 'config/variables'; import coins from 'constants/coins'; @@ -18,6 +18,11 @@ type Props = { toggleGroupCoinsVisibility: typeof LocalStorageActions.toggleGroupCoinsVisibility, }; +type State = { + showAllCoins: boolean, + showAllCoinsExternal: boolean, +}; + const Wrapper = styled.div` display: flex; flex-direction: column; @@ -87,131 +92,173 @@ const LogoWrapper = styled.div` align-items: center; `; -const ToggleAll = styled.span` +const ToggleAll = styled.div` cursor: pointer; `; -const CoinsSettings = (props: Props) => ( - - - - - {props.networks - .filter(network => !network.isHidden) - .map(network => ( - +class CoinsSettings extends PureComponent { + constructor(props: Props) { + super(props); + this.state = { + showAllCoins: this.props.hiddenCoins.length === 0, + showAllCoinsExternal: this.props.hiddenCoinsExternal.length === 0, + }; + } + + render() { + const { props } = this; + return ( + + + + {console.log('hidden coins', props.hiddenCoins)} + {console.log('hidden coins', props.hiddenCoins)} + {console.log('hidden coins external', props.hiddenCoinsExternal)} + - ))} - - - - {coins - .sort((a, b) => a.order - b.order) - .map(network => ( - + + {props.networks + .filter(network => !network.isHidden) + .map(network => ( + + + + + + {network.name} + + + { + props.handleCoinVisibility( + network.shortcut, + visible, + false + ); + }} + checked={!props.hiddenCoins.includes(network.shortcut)} + /> + + + ))} + + + - - -); + + {coins + .sort((a, b) => a.order - b.order) + .map(network => ( + + + + + + {network.coinName} + + + { + props.handleCoinVisibility( + network.id, + visible, + true + ); + }} + checked={ + !props.hiddenCoinsExternal.includes(network.id) + } + /> + + + ))} + + + + ); + } +} export default CoinsSettings;