submitReport(): don't call getState() a million times

This commit is contained in:
Alex Gleason 2022-05-02 14:40:34 -05:00
parent f92eeb333c
commit 83a0988daa
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -56,13 +56,14 @@ export function toggleStatusReport(statusId, checked) {
export function submitReport() {
return (dispatch, getState) => {
dispatch(submitReportRequest());
const { reports } = getState();
return api(getState).post('/api/v1/reports', {
account_id: getState().getIn(['reports', 'new', 'account_id']),
status_ids: getState().getIn(['reports', 'new', 'status_ids']),
rule_ids: getState().getIn(['reports', 'new', 'rule_ids']),
comment: getState().getIn(['reports', 'new', 'comment']),
forward: getState().getIn(['reports', 'new', 'forward']),
account_id: reports.getIn(['new', 'account_id']),
status_ids: reports.getIn(['new', 'status_ids']),
rule_ids: reports.getIn(['new', 'rule_ids']),
comment: reports.getIn(['new', 'comment']),
forward: reports.getIn(['new', 'forward']),
});
};
}