Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3700917
D9062.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D9062.diff
View Options
diff --git a/web/redux/persist.js b/web/redux/persist.js
--- a/web/redux/persist.js
+++ b/web/redux/persist.js
@@ -1,14 +1,27 @@
// @flow
import invariant from 'invariant';
-import { getStoredState, purgeStoredState } from 'redux-persist';
+import {
+ getStoredState,
+ purgeStoredState,
+ createTransform,
+} from 'redux-persist';
import storage from 'redux-persist/es/storage/index.js';
+import type { Transform } from 'redux-persist/es/types.js';
import type { PersistConfig } from 'redux-persist/src/types.js';
import {
createAsyncMigrate,
type StorageMigrationFunction,
} from 'lib/shared/create-async-migrate.js';
+import type {
+ KeyserverInfo,
+ KeyserverStore,
+} from 'lib/types/keyserver-types.js';
+import {
+ defaultConnectionInfo,
+ type ConnectionInfo,
+} from 'lib/types/socket-types.js';
import { isDev } from 'lib/utils/dev-utils.js';
import {
generateIDSchemaMigrationOpsForDrafts,
@@ -103,6 +116,7 @@
'notifPermissionAlertInfo',
'commServicesAccessToken',
'lastCommunicatedPlatformDetails',
+ 'keyserverStore',
];
const rootKey = 'root';
@@ -126,6 +140,50 @@
return oldStorage;
};
+type PersistedKeyserverInfo = $Diff<
+ KeyserverInfo,
+ {
+ +connection: ConnectionInfo,
+ +updatesCurrentAsOf: number,
+ +sessionID?: ?string,
+ },
+>;
+type PersistedKeyserverStore = {
+ +keyserverInfos: { +[key: string]: PersistedKeyserverInfo },
+};
+const keyserverStoreTransform: Transform = createTransform(
+ (state: KeyserverStore): PersistedKeyserverStore => {
+ const keyserverInfos = {};
+ for (const key in state.keyserverInfos) {
+ const { connection, updatesCurrentAsOf, sessionID, ...rest } =
+ state.keyserverInfos[key];
+ keyserverInfos[key] = rest;
+ }
+ return {
+ ...state,
+ keyserverInfos,
+ };
+ },
+ (state: PersistedKeyserverStore): KeyserverStore => {
+ const keyserverInfos = {};
+ const defaultConnection = defaultConnectionInfo;
+ for (const key in state.keyserverInfos) {
+ keyserverInfos[key] = {
+ ...state.keyserverInfos[key],
+ connection: { ...defaultConnection },
+ updatesCurrentAsOf:
+ preloadedState.keyserverStore.keyserverInfos[key].updatesCurrentAsOf,
+ sessionID: preloadedState.keyserverStore.keyserverInfos[key].sessionID,
+ };
+ }
+ return {
+ ...state,
+ keyserverInfos,
+ };
+ },
+ { whitelist: ['keyserverStore'] },
+);
+
const persistConfig: PersistConfig = {
key: rootKey,
storage: commReduxStorageEngine,
@@ -138,6 +196,7 @@
migrateStorageToSQLite,
): any),
version: 3,
+ transforms: [keyserverStoreTransform],
};
export { persistConfig };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 8, 5:23 PM (5 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2820752
Default Alt Text
D9062.diff (2 KB)
Attached To
Mode
D9062: [web] Start persisting keyserverStore
Attached
Detach File
Event Timeline
Log In to Comment