]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Fix 404 and 410 API errors being silently discarded in WebUI
authorThibG <thib@sitedethib.com>
Sat, 28 Mar 2020 16:59:45 +0000 (17:59 +0100)
committerThibaut Girka <thib@sitedethib.com>
Thu, 2 Apr 2020 18:39:44 +0000 (20:39 +0200)
Port front-end changes from 0d117c106aa72f78dd5cdd371849dd8ce3120198 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
app/javascript/flavours/glitch/actions/accounts.js
app/javascript/flavours/glitch/actions/alerts.js
app/javascript/flavours/glitch/actions/identity_proofs.js
app/javascript/flavours/glitch/actions/timelines.js
app/javascript/flavours/glitch/middleware/errors.js

index b659e4ff39038b940678c26f20b2ea86298552dc..e1012a80bc6b4d382fcf221e44ee6c2f21a0926e 100644 (file)
@@ -370,6 +370,7 @@ export function fetchFollowersFail(id, error) {
     type: FOLLOWERS_FETCH_FAIL,
     id,
     error,
+    skipNotFound: true,
   };
 };
 
@@ -456,6 +457,7 @@ export function fetchFollowingFail(id, error) {
     type: FOLLOWING_FETCH_FAIL,
     id,
     error,
+    skipNotFound: true,
   };
 };
 
@@ -545,6 +547,7 @@ export function fetchRelationshipsFail(error) {
     type: RELATIONSHIPS_FETCH_FAIL,
     error,
     skipLoading: true,
+    skipNotFound: true,
   };
 };
 
index cd36d8007bcceeae91a90c9a8abce257d6f3d858..1670f9c10de9f50f8a7cbae2d5849b3021e8356e 100644 (file)
@@ -34,11 +34,11 @@ export function showAlert(title = messages.unexpectedTitle, message = messages.u
   };
 };
 
-export function showAlertForError(error) {
+export function showAlertForError(error, skipNotFound = false) {
   if (error.response) {
     const { data, status, statusText, headers } = error.response;
 
-    if (status === 404 || status === 410) {
+    if (skipNotFound && (status === 404 || status === 410)) {
       // Skip these errors as they are reflected in the UI
       return { type: ALERT_NOOP };
     }
index a7241da20087fea190b52a195b0240fe320fca86..18e679aec49fa476f2604968070cbedb61fb5121 100644 (file)
@@ -27,4 +27,5 @@ export const fetchAccountIdentityProofsFail = (accountId, err) => ({
   type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
   accountId,
   err,
+  skipNotFound: true,
 });
index 2ef78025e393071a308ebd7902bf1f25076ffed0..1bbdd6142bfb4bc6598a17ddee3279a8deb9297d 100644 (file)
@@ -165,6 +165,7 @@ export function expandTimelineFail(timeline, error, isLoadingMore) {
     timeline,
     error,
     skipLoading: !isLoadingMore,
+    skipNotFound: timeline.startsWith('account:'),
   };
 };
 
index 212c1f4ad2c9ea54d564997508ff52d2f50bdd0b..ade529a4ebe441deb7b639c6dcba80fe4367dc42 100644 (file)
@@ -8,7 +8,7 @@ export default function errorsMiddleware() {
       const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
 
       if (action.type.match(isFail)) {
-        dispatch(showAlertForError(action.error));
+        dispatch(showAlertForError(action.error, action.skipNotFound));
       }
     }