mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-30 23:49:04 +01:00
a963ea67dd
Port missing parts from 2c51bc0ca5
to glitch-soc
17 lines
442 B
JavaScript
17 lines
442 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));
|
|
}
|
|
}
|
|
|
|
return next(action);
|
|
};
|
|
};
|