errorsMiddleware: only alert when the error has a response (eg not when offline)

This commit is contained in:
Alex Gleason 2021-10-20 17:50:03 -05:00
parent a16b246d41
commit 5a19d52617
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -3,8 +3,10 @@ import { showAlertForError } from '../actions/alerts';
const isFailType = type => type.endsWith('_FAIL');
const isRememberFailType = type => type.endsWith('_REMEMBER_FAIL');
const shouldShowError = ({ type, skipAlert }) => {
return !skipAlert && isFailType(type) && !isRememberFailType(type);
const hasResponse = error => Boolean(error && error.response);
const shouldShowError = ({ type, skipAlert, error }) => {
return !skipAlert && hasResponse(error) && isFailType(type) && !isRememberFailType(type);
};
export default function errorsMiddleware() {