2020-08-22 08:47:19 +02:00
|
|
|
import { save, load, RLSOptions } from 'redux-localstorage-simple';
|
2022-11-01 12:52:27 +01:00
|
|
|
import { configureStore } from '@reduxjs/toolkit';
|
|
|
|
import reducer from '../reducers';
|
2021-12-23 17:53:06 +01:00
|
|
|
import { migrateDeprecatedSettings } from '../settings/helpers';
|
|
|
|
import { ShlinkState } from './types';
|
2018-12-17 20:03:36 +01:00
|
|
|
|
2022-04-02 08:31:15 +02:00
|
|
|
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'],
|
2020-04-26 19:04:17 +02:00
|
|
|
namespace: 'shlink',
|
|
|
|
namespaceSeparator: '.',
|
2020-05-03 20:16:21 +02:00
|
|
|
debounce: 300,
|
2020-04-26 19:04:17 +02:00
|
|
|
};
|
2021-12-23 17:53:06 +01:00
|
|
|
const preloadedState = migrateDeprecatedSettings(load(localStorageConfig) as ShlinkState);
|
2020-04-26 19:04:17 +02:00
|
|
|
|
2022-11-01 12:52:27 +01:00
|
|
|
export const store = configureStore({
|
|
|
|
devTools: !isProduction,
|
|
|
|
reducer,
|
|
|
|
preloadedState,
|
|
|
|
middleware: (defaultMiddlewaresIncludingReduxThunk) => defaultMiddlewaresIncludingReduxThunk(
|
|
|
|
{ immutableCheck: false, serializableCheck: false }, // State is too big for these
|
|
|
|
).concat(save(localStorageConfig)),
|
|
|
|
});
|