whitelist persisted reducers
Summary: We only want to persist certain reducers that are whitelisted. Currently some parts of the `connections` reducer and everything from the other reducers was persisted. This changes the behavior to only persist what is explicitly whitelisted and not the other reducers. These pars of the store are whitelisted: - `connections.userPreferredDevice` - `connections.userPreferredPlugin` - `connections.userPreferredApp` Reviewed By: jknoxville Differential Revision: D10401403 fbshipit-source-id: e4aa4f2b2f8f6229b02dcf46798965fa1ae74df6
This commit is contained in:
committed by
Facebook Github Bot
parent
51f70fd78c
commit
38268fe4c9
@@ -80,7 +80,6 @@
|
||||
"react-window": "^1.1.1",
|
||||
"redux": "^4.0.0",
|
||||
"redux-persist": "^5.10.0",
|
||||
"redux-persist-transform-filter": "^0.0.18",
|
||||
"rsocket-core": "^0.0.6",
|
||||
"rsocket-tcp-server": "^0.0.6",
|
||||
"socket.io": "^2.0.4",
|
||||
|
||||
23
src/init.js
23
src/init.js
@@ -14,34 +14,15 @@ import Logger from './fb-stubs/Logger.js';
|
||||
import App from './App.js';
|
||||
import BugReporter from './fb-stubs/BugReporter.js';
|
||||
import {createStore} from 'redux';
|
||||
import {persistStore, persistReducer} from 'redux-persist';
|
||||
import createFilter from 'redux-persist-transform-filter';
|
||||
import storage from 'redux-persist/lib/storage/index.js';
|
||||
import autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';
|
||||
import {persistStore} from 'redux-persist';
|
||||
import reducers from './reducers/index.js';
|
||||
import dispatcher from './dispatcher/index.js';
|
||||
import {setupMenuBar} from './MenuBar.js';
|
||||
import TooltipProvider from './ui/components/TooltipProvider.js';
|
||||
const path = require('path');
|
||||
|
||||
const reducer: typeof reducers = persistReducer(
|
||||
{
|
||||
key: 'root',
|
||||
stateReconciler: autoMergeLevel2,
|
||||
transforms: [
|
||||
createFilter('connections', [
|
||||
'userPreferredDevice',
|
||||
'userPreferredPlugin',
|
||||
'userPreferredApp',
|
||||
]),
|
||||
],
|
||||
storage,
|
||||
},
|
||||
reducers,
|
||||
);
|
||||
|
||||
const store = createStore(
|
||||
reducer,
|
||||
reducers,
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__(),
|
||||
);
|
||||
persistStore(store);
|
||||
|
||||
@@ -10,6 +10,8 @@ import application from './application.js';
|
||||
import connections from './connections.js';
|
||||
import pluginStates from './pluginStates.js';
|
||||
import notifications from './notifications.js';
|
||||
import {persistReducer} from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage/index.js';
|
||||
|
||||
import type {
|
||||
State as ApplicationState,
|
||||
@@ -45,7 +47,18 @@ export type Store = ReduxStore<
|
||||
|
||||
export default combineReducers({
|
||||
application,
|
||||
connections: persistReducer(
|
||||
{
|
||||
key: 'connections',
|
||||
storage,
|
||||
whitelist: [
|
||||
'userPreferredDevice',
|
||||
'userPreferredPlugin',
|
||||
'userPreferredApp',
|
||||
],
|
||||
},
|
||||
connections,
|
||||
),
|
||||
pluginStates,
|
||||
notifications,
|
||||
});
|
||||
|
||||
40
yarn.lock
40
yarn.lock
@@ -4253,48 +4253,20 @@ lodash-es@^4.17.5:
|
||||
version "4.17.10"
|
||||
resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.10.tgz#62cd7104cdf5dd87f235a837f0ede0e8e5117e05"
|
||||
|
||||
lodash.clonedeep@^4.5.0:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
|
||||
|
||||
lodash.debounce@^4.0.8:
|
||||
version "4.0.8"
|
||||
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
|
||||
|
||||
lodash.forin@^4.4.0:
|
||||
version "4.4.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.forin/-/lodash.forin-4.4.0.tgz#5d3f20ae564011fbe88381f7d98949c9c9519731"
|
||||
|
||||
lodash.get@^4.4.2:
|
||||
version "4.4.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
|
||||
|
||||
lodash.isempty@^4.4.0:
|
||||
version "4.4.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e"
|
||||
|
||||
lodash.isplainobject@^4.0.6:
|
||||
version "4.0.6"
|
||||
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
|
||||
integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=
|
||||
|
||||
lodash.pickby@^4.6.0:
|
||||
version "4.6.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.pickby/-/lodash.pickby-4.6.0.tgz#7dea21d8c18d7703a27c704c15d3b84a67e33aff"
|
||||
|
||||
lodash.set@^4.3.2:
|
||||
version "4.3.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
|
||||
|
||||
lodash.sortby@^4.7.0:
|
||||
version "4.7.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
|
||||
integrity sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=
|
||||
|
||||
lodash.unset@^4.5.2:
|
||||
version "4.5.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash.unset/-/lodash.unset-4.5.2.tgz#370d1d3e85b72a7e1b0cdf2d272121306f23e4ed"
|
||||
|
||||
lodash@^4.0.1, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.0, lodash@^4.3.0:
|
||||
version "4.17.10"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
|
||||
@@ -5429,18 +5401,6 @@ redux-mock-store@^1.5.3:
|
||||
dependencies:
|
||||
lodash.isplainobject "^4.0.6"
|
||||
|
||||
redux-persist-transform-filter@^0.0.18:
|
||||
version "0.0.18"
|
||||
resolved "https://registry.yarnpkg.com/redux-persist-transform-filter/-/redux-persist-transform-filter-0.0.18.tgz#bc9901a0267bd64631099b4e7bb4d48c00647418"
|
||||
dependencies:
|
||||
lodash.clonedeep "^4.5.0"
|
||||
lodash.forin "^4.4.0"
|
||||
lodash.get "^4.4.2"
|
||||
lodash.isempty "^4.4.0"
|
||||
lodash.pickby "^4.6.0"
|
||||
lodash.set "^4.3.2"
|
||||
lodash.unset "^4.5.2"
|
||||
|
||||
redux-persist@^5.10.0:
|
||||
version "5.10.0"
|
||||
resolved "https://registry.yarnpkg.com/redux-persist/-/redux-persist-5.10.0.tgz#5d8d802c5571e55924efc1c3a9b23575283be62b"
|
||||
|
||||
Reference in New Issue
Block a user