Changeset View
Changeset View
Standalone View
Standalone View
lib/reducers/report-store-reducer.js
// @flow | // @flow | ||||
import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js'; | |||||
import { | import { | ||||
sendReportActionTypes, | sendReportActionTypes, | ||||
sendReportsActionTypes, | sendReportsActionTypes, | ||||
queueReportsActionType, | queueReportsActionType, | ||||
} from '../actions/report-actions.js'; | } from '../actions/report-actions.js'; | ||||
import { siweAuthActionTypes } from '../actions/siwe-actions.js'; | import { siweAuthActionTypes } from '../actions/siwe-actions.js'; | ||||
import { | import { | ||||
logOutActionTypes, | logOutActionTypes, | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | ) { | ||||
return { | return { | ||||
reportStore: { | reportStore: { | ||||
...state, | ...state, | ||||
queuedReports, | queuedReports, | ||||
}, | }, | ||||
reportStoreOperations, | reportStoreOperations, | ||||
}; | }; | ||||
} else if (action.type === setClientDBStoreActionType) { | |||||
const { reports } = action.payload; | |||||
if (!reports) { | |||||
return { | |||||
reportStore: state, | |||||
reportStoreOperations: [], | |||||
}; | |||||
} | |||||
const reportStoreOperations: $ReadOnlyArray<ReportStoreOperation> = [ | |||||
{ | |||||
type: 'remove_all_reports', | |||||
}, | |||||
...convertReportsToReplaceReportOps(reports), | |||||
]; | |||||
const queuedReports = processReportStoreOperations( | |||||
state.queuedReports, | |||||
reportStoreOperations, | |||||
); | |||||
return { | |||||
reportStore: { ...state, queuedReports }, | |||||
reportStoreOperations: [], | |||||
}; | |||||
} | } | ||||
if (newReports) { | if (newReports) { | ||||
const reportStoreOperations: $ReadOnlyArray<ReportStoreOperation> = | const reportStoreOperations: $ReadOnlyArray<ReportStoreOperation> = | ||||
convertReportsToReplaceReportOps(newReports); | convertReportsToReplaceReportOps(newReports); | ||||
const queuedReports = processReportStoreOperations( | const queuedReports = processReportStoreOperations( | ||||
state.queuedReports, | state.queuedReports, | ||||
Show All 14 Lines |