Changeset View
Changeset View
Standalone View
Standalone View
lib/utils/report-utils.js
// @flow | // @flow | ||||
import { useSelector } from './redux-utils.js'; | import { useSelector } from './redux-utils.js'; | ||||
import { getUUID } from './uuid.js'; | |||||
import { | import { | ||||
type SupportedReports, | type SupportedReports, | ||||
type EnabledReports, | type EnabledReports, | ||||
type ClientReportCreationRequest, | type ClientReportCreationRequest, | ||||
reportTypes, | reportTypes, | ||||
} from '../types/report-types.js'; | } from '../types/report-types.js'; | ||||
function useIsReportEnabled(reportType: SupportedReports): boolean { | function useIsReportEnabled(reportType: SupportedReports): boolean { | ||||
Show All 9 Lines | (report.type === reportTypes.MEDIA_MISSION && | ||||
enabledReports.mediaReports) || | enabledReports.mediaReports) || | ||||
(report.type === reportTypes.ERROR && enabledReports.crashReports) || | (report.type === reportTypes.ERROR && enabledReports.crashReports) || | ||||
((report.type === reportTypes.ENTRY_INCONSISTENCY || | ((report.type === reportTypes.ENTRY_INCONSISTENCY || | ||||
report.type === reportTypes.THREAD_INCONSISTENCY) && | report.type === reportTypes.THREAD_INCONSISTENCY) && | ||||
enabledReports.inconsistencyReports) | enabledReports.inconsistencyReports) | ||||
); | ); | ||||
} | } | ||||
export { useIsReportEnabled, isReportEnabled }; | function assignReportsID( | ||||
reports: $ReadOnlyArray<ClientReportCreationRequest>, | |||||
): $ReadOnlyArray<ClientReportCreationRequest> { | |||||
return reports.map((report: ClientReportCreationRequest) => ({ | |||||
...report, | |||||
id: getUUID(), | |||||
tomek: Should we do this only for reports which don't have the `id`? I guess in the migration it… | |||||
kamilAuthorUnsubmitted Done Inline Actionsit turned out that this was a bad assumption - this function will not be used in more places. Also, because id will be mandatory function argument type is not proper - I'll put this code directly into migration. kamil: it turned out that this was a bad assumption - this function will not be used in more places. | |||||
})); | |||||
} | |||||
kamilAuthorUnsubmitted Done Inline Actionsthis function will be re-used in next diff kamil: this function will be re-used in next diff | |||||
export { useIsReportEnabled, isReportEnabled, assignReportsID }; |
Should we do this only for reports which don't have the id? I guess in the migration it doesn't matter, but maybe for other usages of this function will?