Changeset View
Changeset View
Standalone View
Standalone View
lib/ops/report-store-ops.js
Show First 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | function convertReportsToRemoveReportsOperation( | ||||
reports: $ReadOnlyArray<ClientReportCreationRequest>, | reports: $ReadOnlyArray<ClientReportCreationRequest>, | ||||
): RemoveQueuedReportsOperation { | ): RemoveQueuedReportsOperation { | ||||
return { | return { | ||||
type: 'remove_reports', | type: 'remove_reports', | ||||
payload: { ids: reports.map(report => report.id) }, | payload: { ids: reports.map(report => report.id) }, | ||||
}; | }; | ||||
} | } | ||||
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 { | export { | ||||
processReportStoreOperations, | processReportStoreOperations, | ||||
convertReportsToReplaceReportOps, | convertReportsToReplaceReportOps, | ||||
convertReportsToRemoveReportsOperation, | convertReportsToRemoveReportsOperation, | ||||
convertReportStoreOperationToClientDBReportStoreOperation, | |||||
}; | }; |