Page MenuHomePhabricator

D12370.id41150.diff
No OneTemporary

D12370.id41150.diff

diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -33,6 +33,7 @@
} from 'lib/ops/keyserver-store-ops.js';
import {
type ClientDBMessageStoreOperation,
+ type ReplaceMessageStoreLocalMessageInfoOperation,
messageStoreOpsHandlers,
} from 'lib/ops/message-store-ops.js';
import {
@@ -1346,6 +1347,45 @@
state,
ops: [],
}),
+ [76]: async (state: AppState) => {
+ const localMessageInfos = state.messageStore.local;
+
+ const replaceOps: $ReadOnlyArray<ReplaceMessageStoreLocalMessageInfoOperation> =
+ entries(localMessageInfos).map(([id, message]) => ({
+ type: 'replace_local_message_info',
+ payload: {
+ id,
+ localMessageInfo: message,
+ },
+ }));
+
+ const dbOperations: $ReadOnlyArray<ClientDBMessageStoreOperation> =
+ messageStoreOpsHandlers.convertOpsToClientDBOps([
+ { type: 'remove_all_local_message_infos' },
+ ...replaceOps,
+ ]);
+
+ try {
+ await commCoreModule.processDBStoreOperations({
+ messageStoreOperations: dbOperations,
+ });
+ } catch (exception) {
+ if (isTaskCancelledError(exception)) {
+ return {
+ state,
+ ops: [],
+ };
+ }
+ return {
+ state: handleReduxMigrationFailure(state),
+ ops: [],
+ };
+ }
+ return {
+ state,
+ ops: dbOperations,
+ };
+ },
};
// NOTE: renaming this object, and especially the `version` property
@@ -1356,7 +1396,7 @@
storage: AsyncStorage,
blacklist: persistBlacklist,
debug: __DEV__,
- version: 75,
+ version: 76,
transforms: [
messageStoreMessagesBlocklistTransform,
reportStoreTransform,
diff --git a/web/redux/persist-constants.js b/web/redux/persist-constants.js
--- a/web/redux/persist-constants.js
+++ b/web/redux/persist-constants.js
@@ -3,6 +3,6 @@
const rootKey = 'root';
const rootKeyPrefix = 'persist:';
const completeRootKey = `${rootKeyPrefix}${rootKey}`;
-const storeVersion = 75;
+const storeVersion = 76;
export { rootKey, rootKeyPrefix, completeRootKey, storeVersion };
diff --git a/web/redux/persist.js b/web/redux/persist.js
--- a/web/redux/persist.js
+++ b/web/redux/persist.js
@@ -10,7 +10,11 @@
keyserverStoreOpsHandlers,
type ReplaceKeyserverOperation,
} from 'lib/ops/keyserver-store-ops.js';
-import type { ClientDBMessageStoreOperation } from 'lib/ops/message-store-ops.js';
+import {
+ messageStoreOpsHandlers,
+ type ReplaceMessageStoreLocalMessageInfoOperation,
+ type ClientDBMessageStoreOperation,
+} from 'lib/ops/message-store-ops.js';
import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
import { patchRawThreadInfoWithSpecialRole } from 'lib/permissions/special-roles.js';
import { keyserverStoreTransform } from 'lib/shared/transforms/keyserver-store-transform.js';
@@ -512,6 +516,49 @@
state,
ops: [],
}),
+ [76]: async (state: AppState) => {
+ const sharedWorker = await getCommSharedWorker();
+ const isSupported = await sharedWorker.isSupported();
+
+ if (!isSupported) {
+ return {
+ state,
+ ops: [],
+ };
+ }
+
+ const replaceOps: $ReadOnlyArray<ReplaceMessageStoreLocalMessageInfoOperation> =
+ entries(state.messageStore.local).map(([id, localMessageInfo]) => ({
+ type: 'replace_local_message_info',
+ payload: {
+ id,
+ localMessageInfo,
+ },
+ }));
+
+ const messageStoreOperations: $ReadOnlyArray<ClientDBMessageStoreOperation> =
+ messageStoreOpsHandlers.convertOpsToClientDBOps([
+ { type: 'remove_all_local_message_infos' },
+ ...replaceOps,
+ ]);
+
+ try {
+ await sharedWorker.schedule({
+ type: workerRequestMessageTypes.PROCESS_STORE_OPERATIONS,
+ storeOperations: { messageStoreOperations },
+ });
+ return {
+ state,
+ ops: messageStoreOperations,
+ };
+ } catch (e) {
+ console.log(e);
+ return {
+ state: handleReduxMigrationFailure(state),
+ ops: [],
+ };
+ }
+ },
};
const persistConfig: PersistConfig = {

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 26, 1:05 AM (11 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2703494
Default Alt Text
D12370.id41150.diff (4 KB)

Event Timeline