Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function tickMiddleware(store) {
return next => action => {
if (action.type === 'Offline/SCHEDULE_RETRY') {
const intervalId = setInterval(() => {
store.dispatch({ type: 'TICK' });
}, 1000);
setTimeout(() => clearInterval(intervalId), action.payload.delay);
}
return next(action);
};
}
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
let store;
if (process.env.REACT_APP_OFFLINE_API === 'alternative') {
const { middleware, enhanceReducer, enhanceStore } = createOffline(config);
store = createStore(
enhanceReducer(reducer),
undefined,
composeEnhancers(applyMiddleware(middleware, tickMiddleware), enhanceStore)
);
} else {
store = createStore(
reducer,
composeEnhancers(offline(config), applyMiddleware(tickMiddleware))
);
}
export default store;
export default function configureStore(initialState) {
const offline = createOffline({
...offlineConfig,
persist: false,
});
const migrations = {
0: (state) => {
const newState = Object.assign({}, state);
if (newState.weaknesses) {
delete newState.weaknesses;
}
return newState;
},
};
const persistConfig = {
key: 'persist',