diff --git a/src/actions/LocalStorageActions.js b/src/actions/LocalStorageActions.js index 475557fb..2976e23c 100644 --- a/src/actions/LocalStorageActions.js +++ b/src/actions/LocalStorageActions.js @@ -354,7 +354,7 @@ export const getImportedAccounts = (): ?Array => { export const handleCoinVisibility = ( coinShortcut: String, shouldBeVisible: boolean -): ThunkAction => (): void => { +): ThunkAction => (dispatch: Dispatch): void => { const configuration: ?Array = getHiddenCoins(); let newConfig = configuration; const isAlreadyHidden = configuration.find(coin => coin === coinShortcut); @@ -366,6 +366,10 @@ export const handleCoinVisibility = ( } storageUtils.set(TYPE, KEY_HIDDEN_COINS, JSON.stringify(newConfig)); + dispatch({ + type: WALLET.SET_HIDDEN_COINS, + hiddenCoins: newConfig, + }); }; export const getHiddenCoins = (): ?Array => { diff --git a/src/actions/constants/wallet.js b/src/actions/constants/wallet.js index fa3bf052..a32cddfa 100644 --- a/src/actions/constants/wallet.js +++ b/src/actions/constants/wallet.js @@ -19,3 +19,4 @@ export const TOGGLE_SIDEBAR: 'wallet__toggle_sidebar' = 'wallet__toggle_sidebar' export const SET_LANGUAGE: 'wallet__set_language' = 'wallet__set_language'; export const SET_LOCAL_CURRENCY: 'wallet__set_local_currency' = 'wallet__set_local_currency'; export const SET_HIDE_BALANCE: 'wallet__set_hide_balance' = 'wallet__set_hide_balance'; +export const SET_HIDDEN_COINS: 'wallet__set_hidden_coins' = 'wallet__set_hidden_coins'; diff --git a/src/reducers/WalletReducer.js b/src/reducers/WalletReducer.js index fab169a2..2a56c1a7 100644 --- a/src/reducers/WalletReducer.js +++ b/src/reducers/WalletReducer.js @@ -24,6 +24,7 @@ type State = { firstLocationChange: boolean, disconnectRequest: ?TrezorDevice, selectedDevice: ?TrezorDevice, + hiddenCoins: ?Array, }; const initialState: State = { @@ -41,6 +42,7 @@ const initialState: State = { initialPathname: null, disconnectRequest: null, selectedDevice: null, + hiddenCoins: [], }; export default function wallet(state: State = initialState, action: Action): State { @@ -145,6 +147,12 @@ export default function wallet(state: State = initialState, action: Action): Sta hideBalance: action.toggled, }; + case WALLET.SET_HIDDEN_COINS: + return { + ...state, + hiddenCoins: action.hiddenCoins, + }; + default: return state; } diff --git a/src/views/Wallet/views/WalletSettings/components/Coins/index.js b/src/views/Wallet/views/WalletSettings/components/Coins/index.js index 0f00af28..93c1a6b0 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, { Component } from 'react'; +import React from 'react'; import { FormattedMessage } from 'react-intl'; import { FONT_SIZE } from 'config/variables'; @@ -62,41 +62,36 @@ const LogoWrapper = styled.div` align-items: center; `; -class CoinsSettings extends Component { - render() { - const { networks, handleCoinVisibility } = this.props; - return ( - - - - - {networks - .filter(network => !network.isHidden) - .map(network => ( - - - - - - {network.name} - - - { - handleCoinVisibility(network.shortcut, !isVisible); - }} - checked - /> - - - ))} - - - - ); - } -} +const CoinsSettings = (props: Props) => ( + + + + + {props.networks + .filter(network => !network.isHidden) + .map(network => ( + + + + + + {network.name} + + + { + props.handleCoinVisibility(network.shortcut, !isVisible); + }} + checked={props.hiddenCoins.includes(network.shortcut)} + /> + + + ))} + + + +); export default CoinsSettings; diff --git a/src/views/Wallet/views/WalletSettings/index.js b/src/views/Wallet/views/WalletSettings/index.js index 405ed3d0..33929d38 100644 --- a/src/views/Wallet/views/WalletSettings/index.js +++ b/src/views/Wallet/views/WalletSettings/index.js @@ -78,7 +78,6 @@ const buildCurrencyOption = currency => { const WalletSettings = (props: Props) => ( - {console.log(props.localStorage)}
@@ -115,6 +114,7 @@ const WalletSettings = (props: Props) => (