dispatch new action

pull/513/head
Vladimir Volek 5 years ago
parent cc217c7aa1
commit 184d8a2b23

@ -354,7 +354,7 @@ export const getImportedAccounts = (): ?Array<Account> => {
export const handleCoinVisibility = (
coinShortcut: String,
shouldBeVisible: boolean
): ThunkAction => (): void => {
): ThunkAction => (dispatch: Dispatch): void => {
const configuration: ?Array<String> = 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<String> => {

@ -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';

@ -24,6 +24,7 @@ type State = {
firstLocationChange: boolean,
disconnectRequest: ?TrezorDevice,
selectedDevice: ?TrezorDevice,
hiddenCoins: ?Array<String>,
};
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;
}

@ -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 (
<Wrapper>
<Row>
<Label>
<FormattedMessage {...l10nMessages.TR_VISIBLE_COINS} />
</Label>
<Content>
{networks
.filter(network => !network.isHidden)
.map(network => (
<CoinRow key={network.shortcut}>
<Left>
<LogoWrapper>
<CoinLogo height="23" network={network.shortcut} />
</LogoWrapper>
<Name>{network.name}</Name>
</Left>
<Right>
<Switch
onChange={isVisible => {
handleCoinVisibility(network.shortcut, !isVisible);
}}
checked
/>
</Right>
</CoinRow>
))}
</Content>
</Row>
</Wrapper>
);
}
}
const CoinsSettings = (props: Props) => (
<Wrapper>
<Row>
<Label>
<FormattedMessage {...l10nMessages.TR_VISIBLE_COINS} />
</Label>
<Content>
{props.networks
.filter(network => !network.isHidden)
.map(network => (
<CoinRow key={network.shortcut}>
<Left>
<LogoWrapper>
<CoinLogo height="23" network={network.shortcut} />
</LogoWrapper>
<Name>{network.name}</Name>
</Left>
<Right>
<Switch
onChange={isVisible => {
props.handleCoinVisibility(network.shortcut, !isVisible);
}}
checked={props.hiddenCoins.includes(network.shortcut)}
/>
</Right>
</CoinRow>
))}
</Content>
</Row>
</Wrapper>
);
export default CoinsSettings;

@ -78,7 +78,6 @@ const buildCurrencyOption = currency => {
const WalletSettings = (props: Props) => (
<StyledContent>
{console.log(props.localStorage)}
<Section>
<LabelTop>
<FormattedMessage {...l10nMessages.TR_LOCAL_CURRENCY} />
@ -115,6 +114,7 @@ const WalletSettings = (props: Props) => (
<Coins
networks={props.localStorage.config.networks}
handleCoinVisibility={props.handleCoinVisibility}
hiddenCoins={props.wallet.hiddenCoins}
/>
</Section>
<Actions>

Loading…
Cancel
Save