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';
|
2018-04-11 10:06:46 +00:00
|
|
|
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 = {
|
2018-04-11 10:06:46 +00:00
|
|
|
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 = {
|
2018-04-11 10:06:46 +00:00
|
|
|
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) {
|
|
|
|
|
2018-04-11 10:06:46 +00:00
|
|
|
case WALLET.SET_INITIAL_URL :
|
|
|
|
return {
|
|
|
|
...state,
|
2018-04-16 21:19:50 +00:00
|
|
|
initialParams: action.state,
|
2018-04-11 10:06:46 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|