gab-social/app/javascript/gabsocial/middleware/errors.js

19 lines
466 B
JavaScript
Raw Normal View History

2020-03-14 17:31:29 +00:00
// import { showAlertForError } from '../actions/alerts';
2019-07-02 08:10:25 +01:00
const defaultFailSuffix = 'FAIL';
export default function errorsMiddleware() {
return ({ dispatch }) => next => action => {
2020-11-25 21:22:37 +00:00
// : todo : use skipAlert!
2019-07-02 08:10:25 +01:00
if (action.type && !action.skipAlert) {
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
if (action.type.match(isFail)) {
2020-03-14 17:31:29 +00:00
// dispatch(showAlertForError(action.error));
2019-07-02 08:10:25 +01:00
}
}
return next(action);
};
};