Page MenuHomePhabricator

D10784.id36911.diff
No OneTemporary

D10784.id36911.diff

diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -15,6 +15,11 @@
convertCalendarFilterToNewIDSchema,
convertConnectionInfoToNewIDSchema,
} from 'lib/_generated/migration-utils.js';
+import {
+ type ClientDBKeyserverStoreOperation,
+ keyserverStoreOpsHandlers,
+ type ReplaceKeyserverOperation,
+} from 'lib/ops/keyserver-store-ops.js';
import {
type ClientDBMessageStoreOperation,
messageStoreOpsHandlers,
@@ -83,6 +88,7 @@
convertMessageStoreThreadsToNewIDSchema,
convertThreadStoreThreadInfosToNewIDSchema,
} from 'lib/utils/migration-utils.js';
+import { entries } from 'lib/utils/objects.js';
import { defaultNotifPermissionAlertInfo } from 'lib/utils/push-alerts.js';
import { resetUserSpecificState } from 'lib/utils/reducers-utils.js';
import {
@@ -1044,6 +1050,33 @@
handleReduxMigrationFailure,
);
},
+ [62]: async (state: AppState) => {
+ const replaceOps: $ReadOnlyArray<ReplaceKeyserverOperation> = entries(
+ state.keyserverStore.keyserverInfos,
+ ).map(([id, keyserverInfo]) => ({
+ type: 'replace_keyserver',
+ payload: {
+ id,
+ keyserverInfo,
+ },
+ }));
+
+ const dbOperations: $ReadOnlyArray<ClientDBKeyserverStoreOperation> =
+ keyserverStoreOpsHandlers.convertOpsToClientDBOps([
+ { type: 'remove_all_keyservers' },
+ ...replaceOps,
+ ]);
+
+ try {
+ await commCoreModule.processKeyserverStoreOperations(dbOperations);
+ } catch (exception) {
+ if (isTaskCancelledError(exception)) {
+ return state;
+ }
+ return handleReduxMigrationFailure(state);
+ }
+ return state;
+ },
};
// After migration 31, we'll no longer want to persist `messageStore.messages`
@@ -1111,7 +1144,7 @@
storage: AsyncStorage,
blacklist: persistBlacklist,
debug: __DEV__,
- version: 61,
+ version: 62,
transforms: [
messageStoreMessagesBlocklistTransform,
reportStoreTransform,
diff --git a/web/redux/persist.js b/web/redux/persist.js
--- a/web/redux/persist.js
+++ b/web/redux/persist.js
@@ -5,6 +5,11 @@
import storage from 'redux-persist/es/storage/index.js';
import type { PersistConfig } from 'redux-persist/src/types.js';
+import {
+ type ClientDBKeyserverStoreOperation,
+ keyserverStoreOpsHandlers,
+ type ReplaceKeyserverOperation,
+} from 'lib/ops/keyserver-store-ops.js';
import {
createAsyncMigrate,
type StorageMigrationFunction,
@@ -21,6 +26,7 @@
generateIDSchemaMigrationOpsForDrafts,
convertDraftStoreToNewIDSchema,
} from 'lib/utils/migration-utils.js';
+import { entries } from 'lib/utils/objects.js';
import { resetUserSpecificState } from 'lib/utils/reducers-utils.js';
import { ashoatKeyserverID } from 'lib/utils/validation-utils.js';
@@ -44,7 +50,6 @@
'customServer',
];
-// eslint-disable-next-line no-unused-vars
function handleReduxMigrationFailure(oldState: AppState): AppState {
const persistedNonUserSpecificFields = nonUserSpecificFieldsWeb.filter(
field => persistWhitelist.includes(field) || field === '_persist',
@@ -222,6 +227,40 @@
},
};
},
+ [11]: async (state: AppState) => {
+ const databaseModule = await getDatabaseModule();
+ const isDatabaseSupported = await databaseModule.isDatabaseSupported();
+ if (!isDatabaseSupported) {
+ return state;
+ }
+
+ const replaceOps: $ReadOnlyArray<ReplaceKeyserverOperation> = entries(
+ state.keyserverStore.keyserverInfos,
+ ).map(([id, keyserverInfo]) => ({
+ type: 'replace_keyserver',
+ payload: {
+ id,
+ keyserverInfo,
+ },
+ }));
+
+ const keyserverStoreOperations: $ReadOnlyArray<ClientDBKeyserverStoreOperation> =
+ keyserverStoreOpsHandlers.convertOpsToClientDBOps([
+ { type: 'remove_all_keyservers' },
+ ...replaceOps,
+ ]);
+
+ try {
+ await databaseModule.schedule({
+ type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
+ storeOperations: { keyserverStoreOperations },
+ });
+ return state;
+ } catch (e) {
+ console.log(e);
+ return handleReduxMigrationFailure(state);
+ }
+ },
};
const rootKey = 'root';
@@ -268,7 +307,7 @@
{ debug: isDev },
migrateStorageToSQLite,
): any),
- version: 10,
+ version: 11,
transforms: [keyserverStoreTransform],
};

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 9:24 AM (20 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2521472
Default Alt Text
D10784.id36911.diff (4 KB)

Event Timeline