Page MenuHomePhabricator

D4170.diff
No OneTemporary

D4170.diff

diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -4,7 +4,8 @@
import invariant from 'invariant';
import { Platform } from 'react-native';
import Orientation from 'react-native-orientation-locker';
-import { createMigrate } from 'redux-persist';
+import { createMigrate, createTransform } from 'redux-persist';
+import type { Transform } from 'redux-persist/es/types';
import { highestLocalIDSelector } from 'lib/selectors/local-id-selectors';
import { inconsistencyResponsesToReports } from 'lib/shared/report-utils';
@@ -363,6 +364,27 @@
},
};
+// After migration 31, we'll no longer want to persist `messageStore.messages`
+// via redux-persist. However, we DO want to continue persisting everything in
+// `messageStore` EXCEPT for `messages`. The `blacklist` property in
+// `persistConfig` allows us to specify top-level keys that shouldn't be
+// persisted. However, we aren't able to specify nested keys in `blacklist`.
+// As a result, if we want to prevent nested keys from being persisted we'll
+// need to use `createTransform(...)` to specify an `inbound` function that
+// allows us to modify the `state` object before it's passed through
+// `JSON.stringify(...)` and written to disk. We specify the keys for which
+// this transformation should be executed in the `whitelist` property of the
+// `config` object that's passed to `createTransform(...)`.
+// eslint-disable-next-line no-unused-vars
+const messageStoreMessagesBlocklistTransform: Transform = createTransform(
+ state => {
+ const { messages, ...messageStoreSansMessages } = state;
+ return messageStoreSansMessages;
+ },
+ null,
+ { whitelist: ['messageStore'] },
+);
+
const persistConfig = {
key: 'root',
storage: AsyncStorage,

File Metadata

Mime Type
text/plain
Expires
Sat, Dec 21, 6:13 AM (18 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2686599
Default Alt Text
D4170.diff (1 KB)

Event Timeline