logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

errors.js (429B)


  1. import { showAlertForError } from '../actions/alerts';
  2. const defaultFailSuffix = 'FAIL';
  3. export default function errorsMiddleware() {
  4. return ({ dispatch }) => next => action => {
  5. if (action.type && !action.skipAlert) {
  6. const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
  7. if (action.type.match(isFail)) {
  8. dispatch(showAlertForError(action.error));
  9. }
  10. }
  11. return next(action);
  12. };
  13. };