From 5a19d5261780b1834c84602fba888cb728d07669 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 20 Oct 2021 17:50:03 -0500 Subject: [PATCH] errorsMiddleware: only alert when the error has a response (eg not when offline) --- app/soapbox/middleware/errors.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/soapbox/middleware/errors.js b/app/soapbox/middleware/errors.js index edec65a31..b5d9a36a3 100644 --- a/app/soapbox/middleware/errors.js +++ b/app/soapbox/middleware/errors.js @@ -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() {