OSDN Git Service

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