From 3e275e7be58b8b99d5c67fab44443fa6d60cd2e4 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 23 Mar 2018 08:09:01 +0100 Subject: [PATCH] settings persisted to redux store --- app/package.json | 1 + app/src/index.js | 5 +++-- app/src/redux/reducers/settings.js | 2 +- src/main/assets/index.android.bundle | 9 +++++---- src/main/assets/index.android.bundle.meta | 3 ++- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/package.json b/app/package.json index 3eda28f5..ab11b4ce 100644 --- a/app/package.json +++ b/app/package.json @@ -16,6 +16,7 @@ "react-navigation-redux-helpers": "^1.0.1", "react-redux": "^5.0.3", "redux": "^3.6.0", + "redux-logger": "3.0.6", "redux-persist": "^4.8.0", "redux-persist-transform-compress": "^4.2.0", "redux-persist-transform-filter": "0.0.10", diff --git a/app/src/index.js b/app/src/index.js index 826645d6..a889a3e0 100644 --- a/app/src/index.js +++ b/app/src/index.js @@ -87,12 +87,13 @@ const store = createStore( const compressor = createCompressor(); const saveClaimsFilter = createFilter('claims', ['byId', 'claimsByUri']); const subscriptionsFilter = createFilter('subscriptions', ['subscriptions']); +const settingsFilter = createFilter('settings', ['clientSettings']); const persistOptions = { - whitelist: ['claims', 'subscriptions'], + whitelist: ['claims', 'subscriptions', 'settings'], // Order is important. Needs to be compressed last or other transforms can't // read the data - transforms: [saveClaimsFilter, subscriptionsFilter, compressor], + transforms: [saveClaimsFilter, subscriptionsFilter, settingsFilter, compressor], debounce: 10000, storage: AsyncStorage }; diff --git a/app/src/redux/reducers/settings.js b/app/src/redux/reducers/settings.js index 8a76e391..addb7b2b 100644 --- a/app/src/redux/reducers/settings.js +++ b/app/src/redux/reducers/settings.js @@ -13,7 +13,7 @@ reducers[ACTIONS.CLIENT_SETTING_CHANGED] = (state, action) => { const clientSettings = Object.assign({}, state.clientSettings); clientSettings[key] = value; - + return Object.assign({}, state, { clientSettings, }); diff --git a/src/main/assets/index.android.bundle b/src/main/assets/index.android.bundle index a59fcdf9..3b856a83 100644 --- a/src/main/assets/index.android.bundle +++ b/src/main/assets/index.android.bundle @@ -1512,9 +1512,10 @@ __d(function (global, require, module, exports, _dependencyMap) { var compressor = (0, _reduxPersistTransformCompress2.default)(); var saveClaimsFilter = (0, _reduxPersistTransformFilter2.default)('claims', ['byId', 'claimsByUri']); var subscriptionsFilter = (0, _reduxPersistTransformFilter2.default)('subscriptions', ['subscriptions']); + var settingsFilter = (0, _reduxPersistTransformFilter2.default)('settings', ['clientSettings']); var persistOptions = { - whitelist: ['claims', 'subscriptions'], - transforms: [saveClaimsFilter, subscriptionsFilter, compressor], + whitelist: ['claims', 'subscriptions', 'settings'], + transforms: [saveClaimsFilter, subscriptionsFilter, settingsFilter, compressor], debounce: 10000, storage: _reactNative.AsyncStorage }; @@ -1541,13 +1542,13 @@ __d(function (global, require, module, exports, _dependencyMap) { store: store, __source: { fileName: _jsxFileName, - lineNumber: 109 + lineNumber: 110 } }, _react2.default.createElement(_AppNavigator2.default, { __source: { fileName: _jsxFileName, - lineNumber: 110 + lineNumber: 111 } }) ); diff --git a/src/main/assets/index.android.bundle.meta b/src/main/assets/index.android.bundle.meta index b8e17ba9..20061b97 100644 --- a/src/main/assets/index.android.bundle.meta +++ b/src/main/assets/index.android.bundle.meta @@ -1 +1,2 @@ -á…N†eº¸Îù‚ˆ™)5sCÊê \ No newline at end of file +õÚ¤ +’!’óÃÒW€mý6û“­ \ No newline at end of file -- 2.45.2