1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-13 20:08:56 +00:00
trezor-wallet/src/js/reducers/WalletReducer.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-02-20 09:30:36 +00:00
/* @flow */
'use strict';
2018-05-02 11:39:27 +00:00
import * as MODAL from '../actions/constants/modal';
2018-04-11 10:13:38 +00:00
import * as WEB3 from '../actions/constants/web3';
import * as WALLET from '../actions/constants/wallet';
2018-02-20 09:30:36 +00:00
2018-04-16 21:19:50 +00:00
import type { Action, RouterLocationState } from '../flowtype';
2018-02-20 09:30:36 +00:00
type State = {
ready: boolean;
dropdownOpened: boolean;
2018-04-16 21:19:50 +00:00
initialParams: ?RouterLocationState;
initialPathname: ?string;
2018-02-20 09:30:36 +00:00
}
2018-04-16 21:19:50 +00:00
const initialState: State = {
ready: false,
dropdownOpened: false,
initialParams: null,
initialPathname: null,
2018-02-20 09:30:36 +00:00
};
2018-04-16 21:19:50 +00:00
export default function wallet(state: State = initialState, action: Action): State {
2018-02-20 09:30:36 +00:00
switch(action.type) {
case WALLET.SET_INITIAL_URL :
return {
...state,
2018-04-16 21:19:50 +00:00
initialParams: action.state,
initialPathname: action.pathname
}
case WEB3.READY :
return {
...state,
ready: true
}
case WALLET.TOGGLE_DEVICE_DROPDOWN :
return {
...state,
dropdownOpened: action.opened
}
2018-05-02 11:39:27 +00:00
case MODAL.CLOSE :
return {
...state,
dropdownOpened: false
}
2018-02-20 09:30:36 +00:00
default:
return state;
}
}