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, +): $ReadOnlyArray { + 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/redux-setup.js b/native/redux/redux-setup.js --- a/native/redux/redux-setup.js +++ b/native/redux/redux-setup.js @@ -347,6 +347,7 @@ draftStoreOperations, threadStoreOperations, messageStoreOperations, + reportStoreOperations, } = storeOperations; const fixUnreadActiveThreadResult = fixUnreadActiveThread(state, action); @@ -361,7 +362,7 @@ draftStoreOperations, messageStoreOperations, threadStoreOperations: threadStoreOperationsWithUnreadFix, - reportStoreOperations: [], + reportStoreOperations, }); return state; diff --git a/native/redux/redux-utils.js b/native/redux/redux-utils.js --- a/native/redux/redux-utils.js +++ b/native/redux/redux-utils.js @@ -2,6 +2,7 @@ import { useSelector as reactReduxUseSelector } from 'react-redux'; +import { convertReportStoreOperationToClientDBReportStoreOperation } from 'lib/ops/report-store-ops.js'; import type { StoreOperations } from 'lib/types/store-ops-types.js'; import { convertMessageStoreOperationsToClientDBOperations } from 'lib/utils/message-ops-utils.js'; import { convertThreadStoreOperationsToClientDBOperations } from 'lib/utils/thread-ops-utils.js'; @@ -24,12 +25,17 @@ draftStoreOperations, threadStoreOperations, messageStoreOperations, + reportStoreOperations, } = storeOperations; const convertedThreadStoreOperations = convertThreadStoreOperationsToClientDBOperations(threadStoreOperations); const convertedMessageStoreOperations = convertMessageStoreOperationsToClientDBOperations(messageStoreOperations); + const convertedReportStoreOperations = + convertReportStoreOperationToClientDBReportStoreOperation( + reportStoreOperations, + ); try { const promises = []; @@ -52,6 +58,13 @@ commCoreModule.processDraftStoreOperations(draftStoreOperations), ); } + if (convertedReportStoreOperations.length > 0) { + promises.push( + commCoreModule.processReportStoreOperations( + convertedReportStoreOperations, + ), + ); + } await Promise.all(promises); } catch (e) { if (isTaskCancelledError(e)) {