Page MenuHomePhabricator

D7977.id27295.diff
No OneTemporary

D7977.id27295.diff

diff --git a/lib/ops/report-store-ops.js b/lib/ops/report-store-ops.js
--- a/lib/ops/report-store-ops.js
+++ b/lib/ops/report-store-ops.js
@@ -76,8 +76,29 @@
};
}
+function convertReportStoreOperationToClientDBReportStoreOperation(
+ reportStoreOperations: $ReadOnlyArray<ReportStoreOperation>,
+): $ReadOnlyArray<ClientDBReportStoreOperation> {
+ return reportStoreOperations.map(operation => {
+ if (
+ operation.type === 'remove_reports' ||
+ operation.type === 'remove_all_reports'
+ ) {
+ return operation;
+ }
+ return {
+ type: 'replace_report',
+ payload: {
+ id: operation.payload.report.id,
+ report: JSON.stringify(operation.payload.report),
+ },
+ };
+ });
+}
+
export {
processReportStoreOperations,
convertReportsToReplaceReportOps,
convertReportsToRemoveReportsOperation,
+ convertReportStoreOperationToClientDBReportStoreOperation,
};
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -7,6 +7,12 @@
import { createMigrate, createTransform } from 'redux-persist';
import type { Transform } from 'redux-persist/es/types.js';
+import {
+ type ReportStoreOperation,
+ type ClientDBReportStoreOperation,
+ convertReportStoreOperationToClientDBReportStoreOperation,
+ convertReportsToReplaceReportOps,
+} from 'lib/ops/report-store-ops.js';
import { highestLocalIDSelector } from 'lib/selectors/local-id-selectors.js';
import { inconsistencyResponsesToReports } from 'lib/shared/report-utils.js';
import {
@@ -546,6 +552,26 @@
reportStore: { ...state.reportStore, queuedReports },
};
},
+ [42]: (state: AppState) => {
+ const reportStoreOperations: $ReadOnlyArray<ReportStoreOperation> = [
+ { type: 'remove_all_reports' },
+ ...convertReportsToReplaceReportOps(state.reportStore.queuedReports),
+ ];
+ const dbOperations: $ReadOnlyArray<ClientDBReportStoreOperation> =
+ convertReportStoreOperationToClientDBReportStoreOperation(
+ reportStoreOperations,
+ );
+
+ try {
+ commCoreModule.processReportStoreOperationsSync(dbOperations);
+ } catch (exception) {
+ if (isTaskCancelledError(exception)) {
+ return state;
+ }
+ return { ...state, cookie: null };
+ }
+ return state;
+ },
};
// After migration 31, we'll no longer want to persist `messageStore.messages`
@@ -626,7 +652,7 @@
'storeLoaded',
],
debug: __DEV__,
- version: 41,
+ version: 42,
transforms: [messageStoreMessagesBlocklistTransform],
migrate: (createMigrate(migrations, { debug: __DEV__ }): any),
timeout: ((__DEV__ ? 0 : undefined): number | void),

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 23, 2:45 AM (18 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692704
Default Alt Text
D7977.id27295.diff (2 KB)

Event Timeline