Changeset View
Changeset View
Standalone View
Standalone View
lib/reducers/report-store-reducer.js
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | ) { | ||||
); | ); | ||||
return { | return { | ||||
reportStore: { ...state, queuedReports }, | reportStore: { ...state, queuedReports }, | ||||
reportStoreOperations, | reportStoreOperations, | ||||
}; | }; | ||||
} else if (action.type === queueReportsActionType) { | } else if (action.type === queueReportsActionType) { | ||||
const { reports } = action.payload; | const { reports } = action.payload; | ||||
const filteredReports = [...updatedReports, ...reports].filter(report => | const filteredReports = reports.filter(report => | ||||
isReportEnabled(report, state.enabledReports), | isReportEnabled(report, state.enabledReports), | ||||
); | ); | ||||
const reportStoreOperations: $ReadOnlyArray<ReportStoreOperation> = | |||||
convertReportsToReplaceReportOps([...newReports, ...filteredReports]); | |||||
const queuedReports = processReportStoreOperations( | |||||
state.queuedReports, | |||||
reportStoreOperations, | |||||
); | |||||
return { | return { | ||||
reportStore: { | reportStore: { | ||||
...state, | ...state, | ||||
queuedReports: filteredReports, | queuedReports, | ||||
}, | }, | ||||
reportStoreOperations: [], | reportStoreOperations, | ||||
}; | }; | ||||
} | } | ||||
const reportStore = | const reportStore = | ||||
updatedReports !== state.queuedReports | updatedReports !== state.queuedReports | ||||
? { ...state, queuedReports: updatedReports } | ? { ...state, queuedReports: updatedReports } | ||||
: state; | : state; | ||||
return { reportStore, reportStoreOperations: [] }; | return { reportStore, reportStoreOperations: [] }; | ||||
} | } |