Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function configureStore(callback, key) {
const persistConfig = {
keyPrefix: `redux-devtools${key || ''}:`,
blacklist: ['instances', 'socket'],
storage: localForage,
serialize: data => data,
deserialize: data => data
};
getStoredState(persistConfig, (err, restoredState) => {
let composeEnhancers = compose;
if (process.env.NODE_ENV !== 'production') {
if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
}
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
const nextReducer = require('../reducers'); // eslint-disable-line global-require
store.replaceReducer(nextReducer);
});
}
}
const store = createStore(
rootReducer,
return async currentConfig => {
const filePersistStorePath = `${RNFetchBlob.fs.dirs.DocumentDir}/persistStore`;
const isFilePersistStoreExists = await RNFetchBlob.fs.exists(
filePersistStorePath,
);
if (isFilePersistStoreExists) {
const state = await getStoredState(currentConfig);
return state;
}
return getStoredState(v5Config).then(v5State => {
if (v5State) {
return v5State;
}
return getStoredStateV4(v4Config);
});
};
}
async getInitialState({ req, res }) {
const { app, initialState } = this;
const redux = {
initialState
};
await callLifecycle('reduxApplyInitialState', app, { req, res, redux });
if (req.redux.persist) {
try {
const state = await getStoredState(req.redux.persist);
if (state) _.merge(redux.initialState, state);
} catch (err) {}
}
return redux.initialState;
}
async function getInitialState({ cookieJar }, persistConfig) {
const { initialState } = config;
if (cookieJar) {
try {
const state = await getStoredState(persistConfig);
if (state) return state;
} catch (err) {
return initialState;
}
}
return initialState;
}
export default function (configure, callback) {
const persistConfig = typeof chrome !== 'undefined' && chrome.storage && chrome.storage.local ? {
storage,
skipRestore: true,
serialize: data => data,
deserialize: data => data,
debounce: 0
} : {
skipRestore: true
};
getStoredState(persistConfig, (err, initialState) => {
const store = configure(initialState);
persistStore(store, persistConfig, () => { callback(store); });
});
}
async function getInitialState(context, persistConfig) {
if (context.cookieJar) {
let preloadedState = initialState;
try {
preloadedState = await getStoredState(persistConfig);
} catch (err) {}
return preloadedState;
}
return initialState;
}
async getInitialState() {
const { app, initialState } = this;
const redux = {
initialState
};
await callLifecycle('reduxApplyInitialState', app, { redux });
if (app.redux.persist) {
try {
const state = await getStoredState(app.redux.persist);
if (state) return state;
} catch (err) {
return redux.initialState;
}
}
return redux.initialState;
}
export async function verifyStorePassword(password) {
let state = await getStoredState(createConfiguration(password));
let incorrect = Object.values(state).includes(null);
return !incorrect;
};
return async currentConfig => {
const filePersistStorePath = `${RNFetchBlob.fs.dirs.DocumentDir}/persistStore`;
const isFilePersistStoreExists = await RNFetchBlob.fs.exists(
filePersistStorePath,
);
if (isFilePersistStoreExists) {
const state = await getStoredState(currentConfig);
return state;
}
return getStoredState(v5Config).then(v5State => {
if (v5State) {
return v5State;
}
return getStoredStateV4(v4Config);
});
};
}