[Glitch] Fix 404 and 410 API errors being silently discarded in WebUI

Port front-end changes from 0d117c106a to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
pull/1310/head
ThibG 2020-03-28 17:59:45 +01:00 committed by Thibaut Girka
parent f3eff922a3
commit 3eede6f64b
5 changed files with 8 additions and 3 deletions

View File

@ -370,6 +370,7 @@ export function fetchFollowersFail(id, error) {
type: FOLLOWERS_FETCH_FAIL, type: FOLLOWERS_FETCH_FAIL,
id, id,
error, error,
skipNotFound: true,
}; };
}; };
@ -456,6 +457,7 @@ export function fetchFollowingFail(id, error) {
type: FOLLOWING_FETCH_FAIL, type: FOLLOWING_FETCH_FAIL,
id, id,
error, error,
skipNotFound: true,
}; };
}; };
@ -545,6 +547,7 @@ export function fetchRelationshipsFail(error) {
type: RELATIONSHIPS_FETCH_FAIL, type: RELATIONSHIPS_FETCH_FAIL,
error, error,
skipLoading: true, skipLoading: true,
skipNotFound: true,
}; };
}; };

View 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) { if (error.response) {
const { data, status, statusText, headers } = 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 // Skip these errors as they are reflected in the UI
return { type: ALERT_NOOP }; return { type: ALERT_NOOP };
} }

View File

@ -27,4 +27,5 @@ export const fetchAccountIdentityProofsFail = (accountId, err) => ({
type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL, type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
accountId, accountId,
err, err,
skipNotFound: true,
}); });

View File

@ -165,6 +165,7 @@ export function expandTimelineFail(timeline, error, isLoadingMore) {
timeline, timeline,
error, error,
skipLoading: !isLoadingMore, skipLoading: !isLoadingMore,
skipNotFound: timeline.startsWith('account:'),
}; };
}; };

View File

@ -8,7 +8,7 @@ export default function errorsMiddleware() {
const isFail = new RegExp(`${defaultFailSuffix}$`, 'g'); const isFail = new RegExp(`${defaultFailSuffix}$`, 'g');
if (action.type.match(isFail)) { if (action.type.match(isFail)) {
dispatch(showAlertForError(action.error)); dispatch(showAlertForError(action.error, action.skipNotFound));
} }
} }