#48: add accounts reducer and set up localStorage persistance

This commit is contained in:
SleepWalker 2016-10-31 08:51:38 +02:00
parent 7dd58acede
commit 8601da786c
3 changed files with 9 additions and 2 deletions

View File

@ -33,6 +33,7 @@
"react-router": "^2.0.0",
"react-router-redux": "^3.0.0",
"redux": "^3.0.4",
"redux-localstorage": "^0.4.1",
"redux-thunk": "^2.0.0",
"webfontloader": "^1.6.26",
"whatwg-fetch": "^1.0.0"

View File

@ -4,6 +4,7 @@ import { routeReducer } from 'react-router-redux';
import auth from 'components/auth/reducer';
import user from 'components/user/reducer';
import accounts from 'components/accounts/reducer';
import i18n from 'components/i18n/reducer';
import popup from 'components/ui/popup/reducer';
import bsod from 'components/ui/bsod/reducer';
@ -12,6 +13,7 @@ export default combineReducers({
bsod,
auth,
user,
accounts,
i18n,
popup,
routing: routeReducer

View File

@ -4,6 +4,7 @@ import { createStore, applyMiddleware, compose } from 'redux';
// а также дает возможность проверить какие-либо условия перед запуском экшена
// или даже вообще его не запускать в зависимости от условий
import thunk from 'redux-thunk';
import persistState from 'redux-localstorage';
import { syncHistory } from 'react-router-redux';
import { browserHistory } from 'react-router';
@ -15,14 +16,17 @@ export default function storeFactory() {
reduxRouterMiddleware,
thunk
);
const persistStateEnhancer = persistState([
'accounts'
], {key: 'redux-storage'});
/* global process: false */
let enhancer;
if (process.env.NODE_ENV === 'production') {
enhancer = compose(middlewares);
enhancer = compose(middlewares, persistStateEnhancer);
} else {
const DevTools = require('containers/DevTools').default;
enhancer = compose(middlewares, DevTools.instrument());
enhancer = compose(middlewares, persistStateEnhancer, DevTools.instrument());
}
const store = createStore(reducers, {}, enhancer);