[Glitch] Fix 404 and 410 API errors being silently discarded in WebUI
Port front-end changes from 1a993f9675
to glitch-soc
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
This commit is contained in:
parent
631dacf1d7
commit
61052dfa33
5 changed files with 8 additions and 3 deletions
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -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 };
|
||||
}
|
||||
|
|
|
@ -27,4 +27,5 @@ export const fetchAccountIdentityProofsFail = (accountId, err) => ({
|
|||
type: IDENTITY_PROOFS_ACCOUNT_FETCH_FAIL,
|
||||
accountId,
|
||||
err,
|
||||
skipNotFound: true,
|
||||
});
|
||||
|
|
|
@ -165,6 +165,7 @@ export function expandTimelineFail(timeline, error, isLoadingMore) {
|
|||
timeline,
|
||||
error,
|
||||
skipLoading: !isLoadingMore,
|
||||
skipNotFound: timeline.startsWith('account:'),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue