OSDN Git Service

relized the basic step from initialize account
[bytom/bytom-dashboard.git] / src / reducers.js
1 import { combineReducers } from 'redux'
2 import { routerReducer as routing} from 'react-router-redux'
3 import { reducer as form } from 'redux-form'
4 import accessControl from 'features/accessControl/reducers'
5 import { reducers as account } from 'features/accounts'
6 import { reducers as app } from 'features/app'
7 import { reducers as asset } from 'features/assets'
8 import { reducers as balance } from 'features/balances'
9 import { reducers as core } from 'features/core'
10 import { reducers as initialization } from 'features/initialization'
11 import { reducers as mockhsm } from 'features/mockhsm'
12 import { reducers as testnet } from 'features/testnet'
13 import { reducers as transaction } from 'features/transactions'
14 import { reducers as transactionFeed } from 'features/transactionFeeds'
15 import { reducers as tutorial } from 'features/tutorial'
16 import { reducers as unspent } from 'features/unspents'
17 import { clear as clearStorage } from 'utility/localStorage'
18
19 const makeRootReducer = () => (state, action) => {
20   if (action.type == 'UPDATE_CORE_INFO' &&
21       !action.param.isConfigured) {
22     // const newState = {
23     //   form: state.form,
24     //   routing: state.routing,
25     // }
26     //
27     // if (state.core.blockchainId == (action.param.blockchainId || 0)) {
28     //   newState.core = state.core
29     // }
30     //
31     // state = newState
32   } else if (action.type == 'USER_LOG_OUT') {
33     // TODO: see if we can't move this outside of a reducer..
34
35     // Actions still may fire after the location redirect, so make sure they
36     // fire against blank state, and the local storage listener doesn't
37     // persist state.
38     state = undefined
39
40     // Clear tokens and other state from local storage.
41     clearStorage()
42
43     // Finally, reboot the entire dashboard app via a hard redirect.
44     window.location.href = '/'
45   }
46
47   return combineReducers({
48     accessControl,
49     account,
50     app,
51     asset,
52     balance,
53     core,
54     form,
55     initialization,
56     key: mockhsm,
57     routing,
58     testnet,
59     transaction,
60     transactionFeed,
61     tutorial,
62     unspent,
63   })(state, action)
64 }
65 export default makeRootReducer