shlink-web-client/src/container/store.ts

24 lines
876 B
TypeScript
Raw Normal View History

2020-08-22 08:47:19 +02:00
import { save, load, RLSOptions } from 'redux-localstorage-simple';
import { configureStore } from '@reduxjs/toolkit';
import reducer from '../reducers';
import { migrateDeprecatedSettings } from '../settings/helpers';
import { ShlinkState } from './types';
const isProduction = process.env.NODE_ENV === 'production';
2020-08-22 08:47:19 +02:00
const localStorageConfig: RLSOptions = {
2022-03-26 12:17:42 +01:00
states: ['settings', 'servers'],
namespace: 'shlink',
namespaceSeparator: '.',
2020-05-03 20:16:21 +02:00
debounce: 300,
};
const preloadedState = migrateDeprecatedSettings(load(localStorageConfig) as ShlinkState);
export const store = configureStore({
devTools: !isProduction,
reducer,
preloadedState,
middleware: (defaultMiddlewaresIncludingReduxThunk) => defaultMiddlewaresIncludingReduxThunk(
{ immutableCheck: false, serializableCheck: false }, // State is too big for these
).concat(save(localStorageConfig)),
});