mirror of
https://github.com/trezor/trezor-wallet
synced 2025-01-27 16:31:06 +00:00
dispatch new action
This commit is contained in:
parent
cc217c7aa1
commit
184d8a2b23
@ -354,7 +354,7 @@ export const getImportedAccounts = (): ?Array<Account> => {
|
|||||||
export const handleCoinVisibility = (
|
export const handleCoinVisibility = (
|
||||||
coinShortcut: String,
|
coinShortcut: String,
|
||||||
shouldBeVisible: boolean
|
shouldBeVisible: boolean
|
||||||
): ThunkAction => (): void => {
|
): ThunkAction => (dispatch: Dispatch): void => {
|
||||||
const configuration: ?Array<String> = getHiddenCoins();
|
const configuration: ?Array<String> = getHiddenCoins();
|
||||||
let newConfig = configuration;
|
let newConfig = configuration;
|
||||||
const isAlreadyHidden = configuration.find(coin => coin === coinShortcut);
|
const isAlreadyHidden = configuration.find(coin => coin === coinShortcut);
|
||||||
@ -366,6 +366,10 @@ export const handleCoinVisibility = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
storageUtils.set(TYPE, KEY_HIDDEN_COINS, JSON.stringify(newConfig));
|
storageUtils.set(TYPE, KEY_HIDDEN_COINS, JSON.stringify(newConfig));
|
||||||
|
dispatch({
|
||||||
|
type: WALLET.SET_HIDDEN_COINS,
|
||||||
|
hiddenCoins: newConfig,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getHiddenCoins = (): ?Array<String> => {
|
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_LANGUAGE: 'wallet__set_language' = 'wallet__set_language';
|
||||||
export const SET_LOCAL_CURRENCY: 'wallet__set_local_currency' = 'wallet__set_local_currency';
|
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_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,
|
firstLocationChange: boolean,
|
||||||
disconnectRequest: ?TrezorDevice,
|
disconnectRequest: ?TrezorDevice,
|
||||||
selectedDevice: ?TrezorDevice,
|
selectedDevice: ?TrezorDevice,
|
||||||
|
hiddenCoins: ?Array<String>,
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialState: State = {
|
const initialState: State = {
|
||||||
@ -41,6 +42,7 @@ const initialState: State = {
|
|||||||
initialPathname: null,
|
initialPathname: null,
|
||||||
disconnectRequest: null,
|
disconnectRequest: null,
|
||||||
selectedDevice: null,
|
selectedDevice: null,
|
||||||
|
hiddenCoins: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function wallet(state: State = initialState, action: Action): State {
|
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,
|
hideBalance: action.toggled,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
case WALLET.SET_HIDDEN_COINS:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
hiddenCoins: action.hiddenCoins,
|
||||||
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* @flow */
|
/* @flow */
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import React, { Component } from 'react';
|
import React from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { FONT_SIZE } from 'config/variables';
|
import { FONT_SIZE } from 'config/variables';
|
||||||
|
|
||||||
@ -62,17 +62,14 @@ const LogoWrapper = styled.div`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
class CoinsSettings extends Component {
|
const CoinsSettings = (props: Props) => (
|
||||||
render() {
|
|
||||||
const { networks, handleCoinVisibility } = this.props;
|
|
||||||
return (
|
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
<Row>
|
<Row>
|
||||||
<Label>
|
<Label>
|
||||||
<FormattedMessage {...l10nMessages.TR_VISIBLE_COINS} />
|
<FormattedMessage {...l10nMessages.TR_VISIBLE_COINS} />
|
||||||
</Label>
|
</Label>
|
||||||
<Content>
|
<Content>
|
||||||
{networks
|
{props.networks
|
||||||
.filter(network => !network.isHidden)
|
.filter(network => !network.isHidden)
|
||||||
.map(network => (
|
.map(network => (
|
||||||
<CoinRow key={network.shortcut}>
|
<CoinRow key={network.shortcut}>
|
||||||
@ -85,9 +82,9 @@ class CoinsSettings extends Component {
|
|||||||
<Right>
|
<Right>
|
||||||
<Switch
|
<Switch
|
||||||
onChange={isVisible => {
|
onChange={isVisible => {
|
||||||
handleCoinVisibility(network.shortcut, !isVisible);
|
props.handleCoinVisibility(network.shortcut, !isVisible);
|
||||||
}}
|
}}
|
||||||
checked
|
checked={props.hiddenCoins.includes(network.shortcut)}
|
||||||
/>
|
/>
|
||||||
</Right>
|
</Right>
|
||||||
</CoinRow>
|
</CoinRow>
|
||||||
@ -95,8 +92,6 @@ class CoinsSettings extends Component {
|
|||||||
</Content>
|
</Content>
|
||||||
</Row>
|
</Row>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default CoinsSettings;
|
export default CoinsSettings;
|
||||||
|
@ -78,7 +78,6 @@ const buildCurrencyOption = currency => {
|
|||||||
|
|
||||||
const WalletSettings = (props: Props) => (
|
const WalletSettings = (props: Props) => (
|
||||||
<StyledContent>
|
<StyledContent>
|
||||||
{console.log(props.localStorage)}
|
|
||||||
<Section>
|
<Section>
|
||||||
<LabelTop>
|
<LabelTop>
|
||||||
<FormattedMessage {...l10nMessages.TR_LOCAL_CURRENCY} />
|
<FormattedMessage {...l10nMessages.TR_LOCAL_CURRENCY} />
|
||||||
@ -115,6 +114,7 @@ const WalletSettings = (props: Props) => (
|
|||||||
<Coins
|
<Coins
|
||||||
networks={props.localStorage.config.networks}
|
networks={props.localStorage.config.networks}
|
||||||
handleCoinVisibility={props.handleCoinVisibility}
|
handleCoinVisibility={props.handleCoinVisibility}
|
||||||
|
hiddenCoins={props.wallet.hiddenCoins}
|
||||||
/>
|
/>
|
||||||
</Section>
|
</Section>
|
||||||
<Actions>
|
<Actions>
|
||||||
|
Loading…
Reference in New Issue
Block a user