mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-01-16 04:32:57 -05:00
155424e52f
I don't like it changing files this way, but it's basically what c49213f0ea311daba590db1d7a14a641cbd9fe93 and a few others did.
18 lines
462 B
JavaScript
18 lines
462 B
JavaScript
import { showAlertForError } from 'flavours/glitch/actions/alerts';
|
|
|
|
const defaultFailSuffix = 'FAIL';
|
|
|
|
export default function errorsMiddleware() {
|
|
return ({ dispatch }) => next => action => {
|
|
if (action.type && !action.skipAlert) {
|
|
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
|
|
|
|
if (action.type.match(isFail)) {
|
|
dispatch(showAlertForError(action.error, action.skipNotFound));
|
|
}
|
|
}
|
|
|
|
return next(action);
|
|
};
|
|
}
|