mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-05-31 17:46:17 +00:00
Added redux middleware to save parts of the store in the local storage transparently
This commit is contained in:
@@ -29,7 +29,6 @@ const connect = (propsFromState, actionServiceNames = []) =>
|
||||
);
|
||||
|
||||
bottle.serviceFactory('App', App, 'MainHeader', 'Home', 'MenuLayout', 'CreateServer', 'EditServer', 'Settings');
|
||||
bottle.decorator('App', connect(null, [ 'loadRealTimeUpdates' ]));
|
||||
|
||||
provideCommonServices(bottle, connect, withRouter);
|
||||
provideShortUrlsServices(bottle, connect);
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
import ReduxThunk from 'redux-thunk';
|
||||
import { applyMiddleware, compose, createStore } from 'redux';
|
||||
import { save, load } from '@shlinkio/redux-localstorage-simple';
|
||||
import reducers from '../reducers';
|
||||
|
||||
const composeEnhancers = process.env.NODE_ENV !== 'production' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
: compose;
|
||||
|
||||
const store = createStore(reducers, composeEnhancers(
|
||||
applyMiddleware(ReduxThunk)
|
||||
const localStorageConfig = {
|
||||
states: [ 'settings' ],
|
||||
namespace: 'shlink',
|
||||
namespaceSeparator: '.',
|
||||
};
|
||||
|
||||
const store = createStore(reducers, load(localStorageConfig), composeEnhancers(
|
||||
applyMiddleware(save(localStorageConfig), ReduxThunk)
|
||||
));
|
||||
|
||||
export default store;
|
||||
|
||||
Reference in New Issue
Block a user